Description
Part A: Refinancing (refinance.c)
For this part of the program, add to your solution to part B of the previous program. After the
original chart prints out, ask the user to enter the new interest rate for refinancing AND the
closing cost for the refinancing. Using this information, do the following:
1) Print out a revised chart with the refinancing.
2) Print out a single statement stating whether or not the refinancing will create a savings in total
payments made.
To do #1, just do the same exact work as in part A, but using the new interest rate. To do #2,
remember that your total cost is the sum of the payments PLUS the refinancing cost. If this is
less than the total payments with the original numbers, then advise the user to refinance, stating
how much will be saved. Otherwise, tell the user to stick with the original loan and tell them how
much that will save. You are guaranteed that the refinance percentage the user enters will
be lower than the original loan percentage. All values entered may be doubles. The interest
rate is guaranteed to be in between 0 and 20.
Basically, a refinancing is when the loan percentage changes to be a lower value, but because
that courtesy is extended to the home owner, a fee is added to the principle of the loan.
Typically, people only refinance if the savings due to the lower interest rate more than
compensate for the extra loan closing cost.
Sample Program Run #1
What is the value left on the mortgage?
10000
What is the annual interest rate of the loan, in percent?
12
What is the monthly payment?
500
Month Payment Amount Owed
1 500.00 9600.00
2 500.00 9196.00
3 500.00 8787.96
…
22 500.00 211.37
23 213.48 0
What is the loan refinance annual interest rate, in percent?
6
What is the closing cost of the loan?
2000
Here is a revised payment chart:
Month Payment Amount Owed
1 500.00 11560.00
2 500.00 11117.80
3 500.00 10673.39
…
24 500.00 809.94
25 500.00 313.99
26 315.56 0.00
You should not refinance. You will not save any money.
Sample Program Run #2
What is the value left on the mortgage?
10000
What is the annual interest rate of the loan, in percent?
12
What is the monthly payment?
500
Month Payment Amount Owed
1 500.00 9600.00
2 500.00 9196.00
3 500.00 8787.96
…
22 500.00 211.37
23 213.48 0
What is the loan refinance annual interest rate, in percent?
1.5
What is the closing cost of the loan?
1000
Month Payment Amount Owed
1 500.00 10513.75
2 500.00 10026.89
3 500.00 9539.43
…
21 500.00 660.09
22 500.00 160.92
23 161.12 0.00
You should refinance. You will save $52.36.
Part B: Track (track.c)
The following program is taken from a programming contest. The problem description describes
a problem. Your solution to the problem must read the input from the file “track.in”. You should
produce the output to the screen. Two examples of programming contest problems are shown in
the lecture notes for the class. These are the Jetski and Kakuro problems. Please use these as a
general model for how to read in input for these types of problems. The description of the track
problems follows:
Mack and Zack Run on the Track
Filename: track
Dr. Orooji’s sons, Mack and Zack, have competed in their share of sports. Their most recent
obsession has been running. Both Mack and Zack enjoy running around the track at the local
high school. Each of them wants to brag to their dad about their performance every day. The
trouble with this, is that they run in different lanes on the track, so it’s difficult to determine who
has run a longer distance. In particular, a track has two straightaways of equal length and two
semicircles, one at each end. Mack always runs in the inner portion of the track, while Zack
chooses some outer lane:
When Mack brags to his dad, he always mentions how many laps he’s run. Unfortunately, Zack
never runs more laps than Mack (because his lap is longer!), but sometimes he does run longer
than Mack. Your goal will be to determine if Zack ran longer than Mack, and if so, create a boast
Zack can use to retort to Mack mentioning how many laps he ran.
The Problem:
Given the dimensions of the lane where both Mack and Zack run, as well as the number of laps
each of them has run, determine if Zack has run longer than Mack. If he hasn’t, no retort can be
created, since Mack has run more laps and longer than Zack. But, if Zack has run longer, create a
retort exclaiming how many more meters Zack has run than Mack.
The Input:
The first line of input will contain a single positive integer, n (n <100), representing the number
of tracks that Mack and Zack run on. The following n lines will contain descriptions of each
track and how many laps Mack and Zack ran, one line per description.
The first positive integer on each of these lines, L (L ≤ 200), will designate the length of the
straightaway of the track (in meters). The second positive integer on each of these lines, r1 (r1 ≤
100), will be the radius of the inner portion of the track where Mack runs (in meters). The third
positive integer on each of these lines, r2 (r1 < r2 ≤ 200), will be the radius of the outer portion
of the track where Zach runs (in meters). The fourth positive integer on each of these lines, M (M
< 1000), represents the number of laps Mack runs. The final positive integer on each of these
lines, Z (Z < M), represents the number of laps Zack runs. Each value on each of these lines will
be separated by a single space.
The Output:
For each track, out put a header with the following format:
Track #k:
where k represents the 1-based number of the track considered.
If Mack has run longer than Zack, follow this with the exclamation, “Drats!”.
But, if Zack has run longer than Mack, follow this with a statement of the following form:
I’ve run X more meters than Mack!!!
where X represents the number of meters Zack has run in excess of Mack, rounded to the nearest
integer. It is guaranteed that in each input case one of the brothers runs at least .51 meters more
than the other and that this excess distance does not have a fractional part in between .49 and .51,
so that there will be no close rounding cases.
Sample Input:
2
100 50 100 3 2
150 20 100 50 2
Sample Output:
Track #1: I’ve run 114 more meters than Mack!!!
Track #2: Drats!
Deliverables
Two source files: refinance.c, for your solution to problem A and track.c for your solution to
problem B. All files are to be submitted over WebCourses.
Restrictions: Same restrictions apply to this assignment as the previous one!!!