01 - Dastrap - Java Review
01 - Dastrap - Java Review
4. Write the whole code for HelloWorld.java, which outputs the string “Hello World!”
II. Operations
6. Declare 2 integers, assign the first integer with the value of 5, assign the square of this
integer into the second integer.
9. declare an integer called groupNum, using your initial number assigned at the start of the
class, compute for your group number and assign it into the variable groupNum.
10. given 3 doubles (a, b and c), compute for the 2 roots of of a quadratic equation using the
*hint: you may use Math.sqrt(num) to get the square root of num.
III. Conditions
11. Declare 2 integers and assign any value to them. Write if statements for the following: (a) if
the first integer is even, increment it by 1, (b) if the second integer is odd, decrement it by 1.
12. Given an integer, write an if statement that outputs yes if an integer is between 100 and 200.
13. Given an integer, write an if statement that outputs yes if an integer is NOT between 100
and 200.
14. Given an integer, write an if-else statement that outputs if it is positive, negative, or zero.
15. Given an integer, write a switch statement that outputs the number of days in the month that
the given integer corresponds to. (Assume February has 28 days)
IV. Loops
17. Using a while loop, output all the multiples of 10 (from 10 to 100), then print their sum and
average.
19. Using a for loop, compute for the sum of all the odd numbers between 10 and 30.
V. Take home
* *
*** ***
***** *****
*** *******
* *****
n = 5 *** n = 7
a. Initial deposit
b. Interest rate
c. Number of years