





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Professor: Reges; Class: COMPUTER PRGRMNG I; Subject: Computer Science and Engineering; University: University of Washington - Seattle; Term: Autumn 2010;
Typology: Exams
1 / 9
This page cannot be seen from the preview
Don't miss anything!






12 / 3 + 5 + 3 * - 1 + 1 + "(1 + 1)" + 1 + 1 13 / 2 - 38 / 5 / 2.0 + (15 / 10.0) 11 < 3 + 4 || !(5 / 2 == 2) 20 % 6 + 6 % 20 + 6 % 6
public class ParameterMystery { public static void main(String[] args) { int a = 5; int b = 1; int c = 3; int three = a; int one = b + 1; axiom (a, b, c); axiom (c, three, 10); axiom (b + c, one + three, a + one); a++; b = 0; axiom (three, 2, one); } public static void axiom (int c, int b, int a) { System.out.println(a + " + " + c + " = " + b); } }
public static void whileMystery(int x, int y) { while (x > 0 && y > 0) { x = x - y; y--; System.out.print(x + " "); } System.out.println(y); }
whileMystery(7, 5); whileMystery(20, 4); whileMystery(40, 10);
public static int stuff(Random r, int m) { int c = 0; int t = 0; int d = r.nextInt(m); // Point A while (c <= 3) { // Point B d = r.nextInt(6) + 1; if (d <= m) { c++; // Point C } else { c = 0; // Point D } t++; } // Point E return t; } c > 3 d <= m c == 0 Point A Point B Point C Point D Point E
Call Value Returned
baseball(console); // 10 run limit; game called baseball(console); // extra innings baseball(console);
Inning #1: 1 1 Inning #2: 0 0 Inning #3: 2 1 Inning #4: 0 2 Inning #5: 1 0 Inning #6: 1 1 Inning #7: 3 1 Inning #8: 0 0 Inning #9: 1 0 Final score: 9 - 6 Inning #1: 0 1 Inning #2: 1 2 Inning #3: 0 3 Inning #4: 1 1 Inning #5: 0 4 Inning #6: 1 2 Final score: 3 - 13 Inning #1: 0 1 Inning #2: 1 0 Inning #3: 0 3 Inning #4: 1 0 Inning #5: 2 0 Inning #6: 1 2 Inning #7: 1 0 Inning #8: 0 0 Inning #9: 1 1 Inning #10: 0 0 Inning #11: 0 1 Final score: 7 - 8