2002ACTestAnswers

2002ACTestAnswers - CompSci 101 AC 2002 Terms Test MODEL...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: CompSci 101 AC 2002 Terms Test MODEL ANSWERS QUESTION 1 a) 2ter b) 3.34 c) THE CODE WILL COMPILE d) 12 3 4 56 e) System.out.println("\\n\\\n\\\\n"); f) i is: 80 g) d is: 4.5 h)-165 i) 5 QUESTION 2 4 syntax errors: 1) String allStars = ' ************************************* ' ; single quotes, should be double quotes 2) System.out.println(stars + " " + s + " " + stars); missing concatenation operator after the s 3) public static void main(String args) { missing word void 4) printWithStars(name, number ); variable number should be num 1 logic error: 5) String stars = allStars.substring(0, numStars-1 ); numStars-1 should be numStars QUESTION 3 private static int middleNumber(int a, int b, int c) { int max = Math.max(a, Math.max(b, c)); int min = Math.min(a, Math.min(b, c)); return (a+b+c) - (max+min); } QUESTION 4 2.0 no: 10.1 no: 21.5 100.0 QUESTION 5 private static int randomOddDigit() { int num = (int)(Math.random() * 5); return num*2 + 1; } Answer Sheet- Page 2 - CompSci 101 AC QUESTION 6...
View Full Document

Page1 / 3

2002ACTestAnswers - CompSci 101 AC 2002 Terms Test MODEL...

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