# Lab 2 - Roman Numerals

### For each problem Turn in

• The code (as a cpp file),
• A file with the collected outputs from the trial inputs below the run outputs as requested below.
###### Coding Requirements:
1. Follow follow the guidelines on Program Style described in section 2.5 of the textbook. ( See guidelines here).
###### 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.

###### Below is a sample run:
``` [1] Conversion of Arabic Number to Roman Number Format
Enter ARABIC YEAR NUMBER between 1000 and 3000 you want to convert: 1957

In Roman Numeral Format:  MCMLVII

Try Again?[y/n]: y
Enter ARABIC YEAR NUMBER between 1000 and 3000 you want to convert: 2016

In Roman Numeral Format:  MMXVI

Try Again?[y/n]: y
Enter ARABIC YEAR NUMBER between 1000 and 3000 you want to convert: 265
Number should be between 1000 and 3000

Try Again?[y/n]: y
Enter ARABIC YEAR NUMBER between 1000 and 3000 you want to convert: 1245

In Roman Numeral Format:  MCCXLV

Try Again?[y/n]: n
Thank You!
```
###### Turn in runs for the following input:
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 (1/20th) 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.

You can use the tab character to help line up the output. If you cout a "/t" the output will tab over.

###### 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%
###### Two sample runs are given below:
```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

Amount Loaned: 8500
Interest Rate: .0775
A \$8500.00 loan at 7.75% interest.

#       PAYMENT         PRINCIPAL       INTEREST        TOTAL INTEREST  BALANCE
1       425.00          370.10          54.90           54.90           8129.90
2       425.00          372.49          52.51           107.40          7757.40
3       425.00          374.90          50.10           157.50          7382.50
4       425.00          377.32          47.68           205.18          7005.18
5       425.00          379.76          45.24           250.42          6625.42
6       425.00          382.21          42.79           293.21          6243.21
7       425.00          384.68          40.32           333.53          5858.53
8       425.00          387.16          37.84           371.37          5471.37
9       425.00          389.66          35.34           406.70          5081.70
10      425.00          392.18          32.82           439.52          4689.52
11      425.00          394.71          30.29           469.81          4294.81
12      425.00          397.26          27.74           497.55          3897.55
13      425.00          399.83          25.17           522.72          3497.72
14      425.00          402.41          22.59           545.31          3095.31
15      425.00          405.01          19.99           565.30          2690.30
16      425.00          407.63          17.37           582.67          2282.67
17      425.00          410.26          14.74           597.42          1872.42
18      425.00          412.91          12.09           609.51          1459.51
19      425.00          415.57          9.43            618.93          1043.93
20      425.00          418.26          6.74            625.68          625.68
21      425.00          420.96          4.04            629.72          204.72
22      206.04          204.72          1.32            631.04          0.00
Payoff in 22 months (1.83) years

```

Total   100
Problem 1 Run examples with correct output on required trial data   35
Problem 2 Run examples with correct output on required trial data   35
All source code (.cpp)   10
Problem 1 Good clean, easy to understand Input and output operations   5
Problem 1 Complete source code with good formatting, variables names, and comments   5
Problem 2 Good clean, easy to understand Input and output operations   5
Problem 2 Complete source code with good formatting, variables names, and comments   5
Solution
• Roman.gif:

Topic attachments
I Attachment History Action Size Date Who Comment
gif Roman.gif r1 manage 28.1 K 2017-01-17 - 03:02 JimSkon

This topic: SCMP118/Fall2016 > WebHome > Lab2
Topic revision: r20 - 2019-09-12 - 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