Java-4 Answers

Java-4 Answers - num1 = keyboard.nextInt();...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Kenneth O’Malley Starting Out with Java: From Control Structures through Objects Java 4 HW 2/28/2010 Multiple Choice Answers 1. A 2. B 3. C 4. D 5. A 6. A 7. B 8. A 9. C 10. B 11. A 12.D 13. A 14. A 15. D 16. B 17. D 18. B 19. T 20.F 21. F 22.F
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
23.F 24.T 25.T 26.F Find the Error – Page 238 1. again = ‘y’; // initialize to value The while loop is not enclosed in brackets 3. } while (choice == 1); Algorithm Workbench 1. int product = 0, n, input; Scanner keyboard = new Scanner (System.in); System.out.println(“Enter a number: “); input = keyboard.nextInt(); while (product < 100) { product = input * 10; System.out.println(“The value of “ + input + “ * 10 is “ + product); input = product; } 2. do {
Background image of page 2
Kenneth O’Malley Starting Out with Java: From Control Structures through Objects Java 4 HW 2/28/2010 Scanner keyboard = new Scanner (System.in); System.out.println(“Enter first number: “);
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: num1 = keyboard.nextInt(); System.out.println(Enter second number: ); num2 = keyboard.nextInt(); System.out.println(The sum of + num1 + and + num2 is + (num1 + num2)); System.out.println(Would you like to repeat the operation. (Y or N) ); input = keyboard.nextLine(); again = input.char.At(0); } while (again == y | | again == Y); 3. for (number = 0; number &lt;= 1000; number++) { System.out.println((number * 10)); } Short Answers 3. The body of a pretest loop follows the condition of the loop, while a posttest loop will initialize by executing the body before testing the condition. 8. The for loop would be used. 19. The println method writes a newline character, while the print method does not....
View Full Document

Page1 / 3

Java-4 Answers - num1 = keyboard.nextInt();...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online