Answers to Spring 2002 Midterm 2
0|1
0|2
0|3
0|4
1|1
1|2
1|3
1|4
int numSucc = 0;
for (int count = 0; count < 50; count++) {
System.out.println (“How many hot dogs do you want to buy?”);
int toBuy = Keyboard.readInt();
boolean sold = myStand.sellDog(toBuy);
if (sold) {
numSucc++;
}
}
double profits = myStand.getTotProfit();
System.out.println(“Served “ + numSucc + “ customers”);
System.out.println(“Profits: “ + profits);
Please Note – in 2003 – we have covered while, do while, and arrays, that were not on this test in 2002