2003ACTestAnswers

2003ACTestAnswers - CompSci 101 SS C Terms Test 2003...

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

View Full Document Right Arrow Icon
CompSci 101 SS C – Terms Test 2003 Answers to question 1, 2, 10 and 11 QUESTION 1 a) 5.0 b) Total = 51.5 c) Total = " + 5 + 1.5 d) n\ \n e) 100 f) 9 g) 7 h) int rand = ((int)(Math.random() * 50) * 2) + 1; System.out.println(rand); QUESTION 2 4 syntax errors: 1) public Q2 { the keyword class is missing 2) it c; it should be int 3) System.out.print(a + ", " b + " and " + c); missing concatenation operator before the b 4) System.out.println(" is " + average) missing semicolon at the end of the statement 1 logic error: 5) double average = (a + b + c) / 3.0; parentheses missing around a + b + c QUESTION 3 a) true b) true QUESTION 4 > java Q4 line 5 line 8 line 10
Background image of page 1

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

View Full DocumentRight Arrow Icon
QUESTION 5 > java Q5 U UG UGH QUESTION 6 > java Q6 3. letters: HAPPY5 2. word: Y5 1. num: 10 main() num: 3 num 3 (1) main() (4) method3() num 1 5 letters “Happy” “HAPPY5” “Y5” i 5 (3) method2() num 5 word “Happy” “Y5” 10 num (2) method1()
Background image of page 2
QUESTION 7 private static void printNumbers (int num1, int num2 ){ int startNum, endNum; if (num1 < num2){ startNum = num1; endNum = num2; } else { startNum = num2; endNum = num1; } while (startNum <= endNum){ System.out.print(startNum + " ");
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/01/2012 for the course COMPSCI 101 taught by Professor Adrianaferraro during the Summer '12 term at Auckland.

Page1 / 4

2003ACTestAnswers - CompSci 101 SS C Terms Test 2003...

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

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