Answers to Spring 2002 Midterm 2

  1. Not covered yet in 2003
  2. Not covered yet in 2003
  3. Not covered yet in 2003
  4. Not covered yet in 2003
  5. classes – covered midterm #1 in 2003
  6. Not covered yet in 2003
  7. for counter-controlled looping
  8. valid
  9. valid
  10. invalid – type (int) not included in call to method (covered in midterm #1 in 2003)
  11. Not covered yet in 2003
  12.  

0|1

0|2

0|3

0|4

1|1

1|2

1|3

1|4

  1.  Not covered yet in 2003
  2.  Not covered enough to test yet in 2003
  3.  Not covered yet in 2003
  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