CS 111 - Introduction to Computer Science
Homework #2 |
NOTE: Homework that does not compile or is not submitted according to instructions may receive no credit. Do not forget to include your README file (see HW1 for instructions).
1. Introduction: Write a program Intro.java that prints four lines with your (1) name, (2) year, (3) home town, and (4) reason for taking CS 111.
2. Escape Characters: Write a program EscapeChars.java that prints the following two lines:
This is how you print a double-quote ("), a backslash (\), and a lowercase o with stroke (ø). A tab and a newline are printed using a "\t" and "\n", respectively.
The unicode value for lowercase o with stroke can be found here. A full reference for Unicode character values can be found here. Remember that a unicode value is represented in a Java String by following a backslash ("\") and "u" with a 4 hexadecimal digit unicode number. (See Liang section 4.3.1, p. 125.)
3. Convert Celsius to Fahrenheit: Text Programming Exercise 2.1 (p. 70). Call your program CelsiusToFahrenheit.java.
4. Future Investment Value: Text Programming Exercise 2.21 (p. 75). Call your program FutureValue.java. Let the "monthlyInterestRate" be the annual interest rate divided by 12. For this exercise, omit fractions of cents, i.e. a future dollar values of 1.259829384 would be printed as $1.25. Hint: Casting to an int, i.e. "(int)", throws away fractional parts. How can you throw away fractional cents rather than fractional dollars?
Rubric: (20 points total)