For each of the following, correct the syntax errors.
1. if x > 25.0 y = x else y = z; 2. if (x >> 0); System.out.println("positive " + x); else; System.out.println("negative " + x);What is the output of each of the following statements? Assume that x = 5, y = 2, z = 10, and temp = 0
3. if (y >= x) y = z; System.out.println(x + " " + y + " " + z); 4. if (y >= x) { y = z; System.out.println(x + " " + y + " " + z); } 5. if (x >= 6) System.out.println(x + y); System.out.println(x + y); 6. if (x + y > z) x = y + z; else x = y - z; System.out.println(x + " " + y + " " + z);
Write if statements for the following problems. Use meaningful variable names. You can assume that the variables you use are declared and have been initialized.
7. If a variable angle is equal to 90 degrees, print the message "right angle. Otherwise print the message "not a right angle". 8. If the difference between variables temp1 and temp2 is more than 2.3, set the variable approx to (temp1 - temp2) * factor. 9. A student at State U is ready to graduate if he or she has completed at least 122 credits. Write the statements to test whether a student is ready to graduate, and print a message telling whether he or she is ready.
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2013