# CIS 5100 Data Structures and Programming (Java)

1. A (5 points) Define the term “algorithm”.

B (5 points) What is UML?

What is it good for?

C (3 points) Write a

program that decides whether integer number input1 can be divided by integer

number input2 without remainder. The

program should output “No Remainder” if there is no remainder and “Remainder

is: ” if there is any. In this latter

case, the program should output the value of the remainder as well.

D (6 points) Write

a program line that generates the following stream output

2. A

(6 points) What is compilation?

What does the

compiler do? (Explain with your own

words.)

B (7 points) How many

control statements does Java have?

There are 7 control

statements in Java:

Name the control statements

of Java.

Give at least 1

example for each.

C (5

points) Draw an activity diagram for the

following piece of code:

D (8 points) Write

a FOR loop that sums even integers from 4 through 54 AND

prints out the FINAL result only.

3. A (3

points) Write a piece of code in Java that

sets the value of “int Number” randomly from the following set: {404, 405, 406, 407, 408}.

B (5 points) Write a program segment in java that

sets the value of “int Number” randomly from the following set: {404, 405, 406, 407, 411}. !

C (11 points)Pythagorean Triples. The set of three integer values for the

lengths of the sides of a right triangle is called a Pythagorean Triple. These three sides must satisfy the

relationship that the sum of the squares of two of the sides is equal to the

square of the hypotenuse.

Specifically:

a*a + b*b = c*c

is true if and

only of the triangle is a right triangle.

Write a method that

gets 3 input integers and checks whether those in any order represent a

Pythagorean Triple. The method returns

‘p’ if the numbers are of Pythagorean Triples and returns ‘n’ otherwise.

D (11 points)Write a program that prints out primes

in a decreasing order between 1 and 59.

(1 is considered to be a prime here.)

4. A (7 points) An

enhanced for statement loops through an array. The syntax is for ( parameter : arrayName ) statement

How would you use a

regular for

statement to replace an enhanced one

Draw the

activity diagram of the enhanced for. (Parameter goes in order for first

to last, no index needed)

B (7 points)Write a program that prints the

following array’s values in descending order

C (7 points) A

palindrome is a number or text phrase that reads the same backwards as

forwards. For example, each of the

following five-letter words is a palindrome: abcba, ghihg, bbbbb.

Write a program containing a method that

determines whether a five-digit word is a palindrome.

D (4 points)What does the following program do? Explain

line-by-line and then give the output.

Click

BUY NOW BUTTON For Solution

You'll get a 312.5KB .DOC file.