Write a program that sums the odd numbers between 0 and 50


Assignment

For questions 2-9 you must submit your code together with the output of running your code on some sensible sample input. Submit the input and the output of your program along with your code.

Question 1

Consider the following code:

int count = 0;

while(count < 100)

{

// Point A

System.out.println("Java");

count++;

// Point B

}

// Point C

Is count < 100 always true, always false, or sometimes true or sometimes false at Points A, B and C in the code?

Question 2

Write a program that sums the odd numbers between 0 and 50.

Question 3

Write a program that reads from the keyboard a value, N, and prints the sum of the odd numbers

between 0 and N.

Question 4

Write a program that reads from the keyboard a value, N, and prints the even multiples of N between 0

and 100.

Question 5

Write a program that reads from the keyboard a value, N, and prints the sum of the squares of the

numbers from 0 to N.

Question 6

Write a program which reads (from the keyboard) numbers (doubles) until a zero is input and computes

the maximum and minimum of all the read numbers (excluding the terminating zero).

Note: you must allow for negative as well as positive numbers.

Hint: look at java.lang.Double.MAX_VALUE and java.lang.Double.MIN_VALUE.

Question 7

Write a program that reads from the keyboard:

• A double, P, representing the principal of the investment (i.e. the initial amount of the

investment).

• An integer, N, representing the term of an investment (i.e. the number of years for the

investment).

• A double, R, representing the rate of return of the investment per year as a percentage (e.g: an

input of 25.5 means you earn 25.5% interest per year).

For each year of the investment your program must then output the value of the investment at the

beginning of the year, the interest earned that year, and the value of the investment at the end of the year.

Question 8

Write a Java program that prints out the products I * J, for I between 1 and 5, and J between 1 and 5.

Question 9

Write a program that finds the smallest positive integer, N, such that N2 > 12000.

Do NOT use the Math.sqrt function.

Solution Preview :

Prepared by a verified Expert
Programming Languages: Write a program that sums the odd numbers between 0 and 50
Reference No:- TGS01724322

Now Priced at $40 (50% Discount)

Recommended (90%)

Rated (4.3/5)