Computer Science
15-111 (Sections A & B), Spring 2007
Homework #2 (part 2)
Due: Mon
22-Jan-2007, 8pm (online submisson).
SOLUTIONS
Note: instructions for submitting this assignment
will be discussed in class on Monday, hence the extension to 8pm that day. Late assignments are still due by Tuesday at
5pm.
Write the
following Java programs. Be sure to use
good style, including a good user interface which never throws exceptions (even
for “illegal” input!). Provide
meaningful prompts for input, and concise output explaining your program’s
results. Also, be sure your variables
have meaningful names whenever possible.
Although
you would ordinarily use methods for these problems, we have not reviewed them
yet (that’s Monday’s lecture!), so they are not required for this
assignment. For each program, you can
place all your code (just this once!) inside a main method.
Note: These programs are not always written with
ideal style, and as such are not always complete solutions. They are meant to be complete enough for you
to understand everything needed for your solutions.
3. IsPrime.java