```
CS1401, Fall 2007

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

Problem 1:

** 3*10^8 is not a legal way to describe numbers, we need 3.0E8

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

** Java's raising to power is power not ^

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

* In Java, (a)(b) does not mean multiplication, you have to
explicitly include a multiplication symbol

Problem 2:

** several students, in addition to doubling the mass (as required),
also doubled the speed of light, for no reason at all

** 3*10^8 is not a legal way to describe numbers, we need 3.0E8

** 10e8 does not mean 10 to the power 8, it means 10 times 10 to the
power 8, i.e., 10 to the power 9

** many students do not know how to operate with numbers in scientific
notation, quite a few thought that 2 * (3*10^8) is 9*10^16

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

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

* some students did not double the mass at all

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

* 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 energy(double m, double v){

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

Problem 3:

** we are supposed to have only one array, of masses, c is a constant
not an array; this is OK, because students were confused by my
comment during the test

Problem 4:

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

** in tracing, it is desirable to separate local variables (which are
only defined inside a method) from the global variables (defined in
the main method); for this, we must clearly describe a method, and
describe which variables are defined in its header and in its body

** not tracing all values; tracing wrong: e.g., if the initialization
of a loop index is i=1, the value of i is never 0

** not defining a method at all

* minor thing: when an array is defined as

double [] textbooks = {1.0, 0.5, 2.0};

the elements of this array are immediately assigned correct values;
there is no intermediate step on which the values are zeros
```