# Lab 2

### Instructions

• Turn in the code (a cpp file or ideone.com link) for each, and the run outputs as requested below.
• Remember to format the code as described and the book and text, and to include comments including complete comment the beginning of the program.

```//File Name: health.cpp
//Author: Your Name Goes Here.
//Email Address: you@yourmachine.bla.bla
//Assignment Number: 2
//Description: Program to determine if the user is ill.
//Last Changed: September 23, 2015
```

### Grading

Feature %
Program correctness and completeness with respect to defination 70%
Code Format (Indenting, variable names) 10%
Code Comments 10%
Turning in complete runs as requested 10%

### Problem 1

Write a program that accepts a year written as a four-digit Arabic (ordinary) numeral and outputs the year written in Roman numerals. Important Roman numerals are V for 5, X for 10, L for 50, C for 100, D for 500, and M for 1,000. Recall that some numbers are formed by using a kind of subtraction of one Roman “digit”; for example, IV is 4 produced as V minus I, XL is 40, CM is 900, and so on. A few sample years: MCM is 1900, MCML is 1950, MCMLX is 1960, MCMXL is 1940, MCMLXXXIX is 1989. Assume the year is between 1000 and 3000. Your program should include a loop that lets the user repeat this calculation until the user says she or he is done.

Your program should give an appropriate error if the input is not a valid four-digit year between 1000 and 3000.

Turn in runs for:

1. 1650
2. 2033
3. 1999
4. 2001
5. A year that is too small
6. A year that is too large

### Problem 2

Interest on a loan is paid on a declining balance, and hence a loan with an interest rate of, say, 14% can cost significantly less than 14% of the balance. Write a program that takes a loan amount and interest rate as input and then outputs the monthly payments and balance of the loan until the loan is paid off. Assume that the monthly payments are one-twentieth of the original loan amount, and that any amount in excess of the interest is credited toward decreasing the balance due. Thus, on a loan of \$20,000, the payments would be \$1,000 a month. If the interest rate is 10%, then each month the interest is one-twelfth of 10% of the remaining balance. The first month, (10% of \$20,000)/12, or \$166.67, would be paid in interest, and the remaining \$833.33 would decrease the balance to \$19,166.67. The following month the interest would be (10% of \$19,166.67)/12, and so forth. Also have the program output the total interest paid over the life of the loan.

For each input, please print out a full amortization table as seen in the example below. Your program should ask for a loan amount, and an interest percentage. The output should be in fixed number format with 2 digit after the decimal point.

Turn in runs with the following inputs:

1. Loan: \$10,000, Interest: 5.5%
2. Loan: \$4,500, Interest: 13.35%
3. Loan: \$120,000, Interest: 3.55%

```A \$20000.00 loan at 10.00% interest.

#   PAYMENT      PRINCIPAL   INTEREST   TOTAL INTEREST   BALANCE
1   1000.00      833.33      166.67      166.67         19166.67
2   1000.00      840.28      159.72      326.39         18326.39
3   1000.00      847.28      152.72      479.11         17479.11
4   1000.00      854.34      145.66      624.77         16624.77
5   1000.00      861.46      138.54      763.31         15763.31
6   1000.00      868.64      131.36      894.67         14894.67
7   1000.00      875.88      124.12      1018.79         14018.79
8   1000.00      883.18      116.82      1135.61         13135.61
9   1000.00      890.54      109.46      1245.08         12245.08
10   1000.00      897.96      102.04      1347.12         11347.12
11   1000.00      905.44      94.56      1441.68         10441.68
12   1000.00      912.99      87.01      1528.69         9528.69
13   1000.00      920.59      79.41      1608.10         8608.10
14   1000.00      928.27      71.73      1679.83         7679.83
15   1000.00      936.00      64.00      1743.83         6743.83
16   1000.00      943.80      56.20      1800.03         5800.03
17   1000.00      951.67      48.33      1848.36         4848.36
18   1000.00      959.60      40.40      1888.77         3888.77
19   1000.00      967.59      32.41      1921.17         2921.17
20   1000.00      975.66      24.34      1945.52         1945.52
21   1000.00      983.79      16.21      1961.73         961.73
22   969.74      961.73      8.01      1969.74         0.00
Payoff in 22 months (1.83) years

```

This topic: KenyonCpp > WebHome > Lab2
Topic revision: r8 - 2015-09-28 - JimSkon

Copyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback