Midterm 1 with solutions

1. (25 points) Write a program that reads a text from the keyboard
up to a new line. The program will then count
the number of punctuation marks (``.'', ``,'', ``;'', ``:'',
``!'', ``?'') found in the text.

Sample run:

It was a dark and stormy night, the wind was blowing and the children were sca
red... Bang ! What was that ? The loud noise was soon explained: a tree had fa
llen over.
Number of '.' : 4
Number of ',' : 1
Number of ';' : 0
Number of ':' : 1
Number of '!' : 1
Number of '?' : 1

Notes and hints:

The input is terminated by a new line, so you have to read
1 character at a time up to '\n'.

2. (25 points) We want to write a mortgage calculator. It
will simply display month by month what is the outstanding balance
on the mortgage at the end of each month for the first year. The
inputs are: