CS1401, Fall 2007

Mistakes for Test 3, 11:30 am version; typical mistakes are marked
by **

Problem 1:

** not including parameters in the header of the method

** not tracing the values of all the variables

** It is better not to use the same name for the formal and the
actual parameters of a method

** a method returning a double is not a constructor, so you should
not place "new" before the call to this method

** 450,000 is not legal in Java: commas are not allowed

* Not calling your method at all

* calling it in a wrong way

Problem 2:

** tracing skips some variables and computations; the idea is to follow
computations step-by-step and check that the final results are

Tracing is NOT describing what your program SHOULD do, it is
describing what your program ACTUALLY does -- to make sure that it
does what is should do

** since the price of the ticket does not change, there is no need to
re-set it again; the re-setting is not wrong, but it shows some lack
of understand of what the objects do -- exactly what we were trying
to check when asking to trace

** when a method is defined inside a class that uses the values of
the class fields, this method should call these values and not ask
for unrelated values; for example,

public double profit(double p, int s, double e){

will take values from outside but NOT the values of the fields

** 450,000 is not legal in Java: commas are not allowed

* no method for computing profit at all

* in Java, it is not possible to write an assignment statement like
   x = $50;
values are real numbers, we can have
   x = 50.0;
   x = 50;

* no space is allowed inside the variable name; newSeats is a legal
name, new Seats is not

* a method for computing energy has to be inside the class, not
outside it

Problem 3:

** variable i describing a loop index not only gets value 0 and 1,
its value actually goes all the way to 2; it should be traced

** erroneously calling an array p instead of its element p[i]

* defining an array inside a loop; this defines an array twice, and
we can only define it once

* trying to define two arrays of 3 elements instead of, as required,
3 arrays with 2 elements in each; this was a confusion probably
caused by a typo in the original test

Problem 4:

** finding the largest attendance, while the question was to find the
CONCERT with the largest attendance