Homework 2

Due Thurs Nov 4, 18:00


Exercise 1: (5 points)

Chapter 2 Programming Project #9 (page 145)

Name your class SillySentence and your source file SillySentence.java

Exercise 2: (5 points)

Write a program that produces the following user dialog (the user input is displayed in red; underlined text is program output that is based on user input):

Hello! What's your name?
Bob Smith
What are you doing?
writing a program
Oh. Why are you writing a program?
Because I'm learning to program.
Good luck writing a program, Bob Smith.
Goodbye!

Optional: Make your program produce the same response even if the user types
i'm writing a program

Hint: use the replace method of the String class  (replace("old", "new"))

Name your class Greeting and your source file Greeting.java


Submit the following files to Anne (javaiscl (at googlemail.com)):
SillySentence.java
Greeting.java