CS 111 - Introduction to Computer Science
Homework #2


Due at the beginning of class 6.

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 (in the last section "Programming Exercises From The Book", under "Sections 2.2-2.13").  Call your program CelsiusToFahrenheit.java.

Note: Previous editions had the prompt "Enter a degree in Celsius: ". Starting with the 13th edition, the prompt is "Enter a temperature in Celsius: ". Tests have been updated to the 13th edition.

Sample transcript (input underlined):

Enter a temperature in Celsius: 12.3
12.3 Celsius is 54.14 Fahrenheit

4. Future Investment Value: Text Programming Exercise 2.21.  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?

Sample transcript (input underlined):

Enter the investment amount, for example 120000.95: 12.34
Enter annual interest rate, for example 8.25: 6.5
Enter number of years as an integer, for example 5: 40
Future value is $164.98

Note: There have been substantial input/output changes in edition 13 from what came before. The tests have been updated to the 13th edition.

Rubric: (20 points total)