This problem set covers Chapter 2.

Split 4 Digit Number (5 points)

(Programming Projects #4, Page 130) Write a program that reads a four-digit integer, such as 1998, and then displays it, one digit per line, like so:

1
9
9
8

Your prompt should tell the user to enter a four-digit integer. You can then assume that the user follows directions. (Hint: Use the division and remainders operators.)

Change Hate to Love (5 points)

(Programming Projects #7, Page 130) Write a program that reads a line of text and then displays the line, but with the first occurrence of hate changed to love. For example, a possible sample dialogue might be:

Enter a line of text.
I hate you.
I have rephrased that line to read:
I love you.

You can assume that the word hate occurs in the input. If the word hate occurs more than once in the line, your program will replace only the first occurrence.

Vending Machine Makes Change (5 points)

(Programming Projects #10, Page 131) Write a program that determines the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents and a dollar, in 5-cent increments (25, 30, 35, ... , 90, 95, and 100), and the machine accepts only a single dollar bill to pay for the item. For example, a possible dialogue with the user might be:

Enter the price of item
(From 25 cents to a dollar, in 5-cent increments): 45
You bought an item for 45 cents and gave me a dollar,
so your change is:
2 quarters,
0 dimes
1 nickel