DASTRAP – Review of Java Programming ConceptsMay 28, 2009
I. Warm-ups – Variables, basics
1. Declare 1 char, 1 float, and 1 doubles.2. Assign your group number to all 3 variables.3. Output (use System.out.println) the sum of the float and double.4. Write the whole code for HelloWorld.java, which outputs the string “Hello World!”5. Write the println statement to output:
/ \ / \ ” backslash§
II. Operations
6. Declare 2 integers, assign the first integer with the value of 5, assign the square of thisinteger into the second integer.7. Declare a double with an initial value of 5 and triple its value.8. increment the double in #7 by 1.9. declare an integer called groupNum, using your initial number assigned at the start of theclass, 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 thequadratic formula
use only 2 lines of code for this.
*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 100and 200.14. Given an integer, write an if-else statement that outputs if it is positive, negative, or zero.
Leave a Comment