Typical mistakes on Test 1, CS1401, Fall 2013

Problem 2: an identifier must start with a letter and have only
digits, letters, and underscores ($ is OK but not recommended); any
other symbol makes it not an identifier; it is OK to start with a
capital letter (this is how classes are named), but not OK to have
- or : inside; and do not forget about reserved words of Java

Problem 3:

* read assignment attentively; sometimes the Java code is missing;
sometimes, the explanation of what comes first is missing

* when you have / followed by multiplication, division is
implemented first

* in Java, ^2 does not mean squaring; to get x squared, you must
write x * x

* you cannot write (a)(b) and expect Java to understand it
multiplication, the multiplication symbol should be explicitly

* 1/2 in Java means division of integers, so it leads to 0; you
need 1.0/2 or (double)1/2 to make it non-zero

* Java code must be in one line, for example, a fraction has to be
1/2, you cannot write anything above or below the line

* System.out.println(xy) will NOT print two values of x and y, it
will think that xy is a name of the new variable

Problem 4-5:

* a constant has to start with "final", and its name should be in
all caps

* make sure that when you declare something a constant, all
instances are replaced by the name of this constant, this is the
whole purpose of making something a constant: that if you need to
change its value, you only change one line;

* you need to first ask the user for the information, then read it, and then
compute; you cannot start computing before you get that information

* please be attentive, some of you did not print exactly as we
asked, missing some parts of the required memo

* every variable needs to be declared, with an appropriate type; if
you declare a variable of type Scanner, you cannot add it or
multiply it

Problem 6:

* it is not possible to assign a double value to an integer
variable; in general, you can only automatically assign a value
from a less general class to a value from a more general class, and
since every integer is a real number, real numbers are more general
than integers;

* if == or -- is in front of the variable, this means that this
variable is incremented or decremented first, and the new value is
used in all other operations;s if -- or ++ are after the variable,
first all operations are performed with the old value, and only
after that, this value is incremented or decremented