Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need help with my code so it looks like the example Write a C++ program which prompts the user for the following: The loan

i need help with my code so it looks like the example

Write a C++ program which prompts the user for the following:

The loan amount (220,000); the interest rate (5.4); and the length of the loan in years (30). Print out the payment period; Interest; Principle; and Balance for each month. Print the total Interest at the end. (if for some reason your program does not print all 360 payments you can add a cin.get() at the end of your code and that should take care of the issue)

Please enter your beginning balance in dollars.

220000

Please enter your annual interest rate in percent.

5.4

Please enter your payment terms in years.

30

Your Monthly Payment is: $1235.37

Period Interest Principal Balance

1 $990.00 $245.37 $219754.63

2 $988.90 $246.47 $219508.16

3 $987.79 $247.58 $219260.58

4 $986.67 $248.70 $219011.88

5 $985.55 $249.81 $218762.07

6 $984.43 $250.94 $218511.13

7 $983.30 $252.07 $218259.06

8 $982.17 $253.20 $218005.86

9 $981.03 $254.34 $217751.52

10 $979.88 $255.49 $217496.03

11 $978.73 $256.64 $217239.40

12 $977.58 $257.79 $216981.61

.......

358 $16.53 $1218.84 $2454.16

359 $11.04 $1224.32 $1229.83

360 $5.53 $1229.83 $-0

code:

#include #include #include #include #include #include #include

using namespace std;

int main() { double M = 0.0; double pay = 0.0; double ment = 0.0; double payment = 0.0; double P = 0.0; double i = 0.0; double N = 0.0; cout << setprecision(2) << fixed; cout << "Please enter your beginning balance in dollars. " << endl; cin >> P; cout << "Please enter your annual interest rate in percent. " << endl; cin >> i; cout << "Please enter your payment terms in years. " << endl; cin >> M; i = (i / 100.0) / 12.0; N = M * 12.0; pay = ((pow((1.0 + i), N)) * i); ment = ((pow((1.0 + i), N)) - 1.0); payment = P * ((pay) / (ment)); cout << "Your Monthly Payment is: $" << payment << endl; double balance = P; for (double e = 0.0; i <= N; e++){ double interest = P * i; double principal = payment - interest; balance = P - principal; cout << "Period Interest Principal Balance" << endl; cout << e << "\t" << interest << "\t" << principal << "\t" << balance << endl; } return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

T Sql Fundamentals

Authors: Itzik Ben Gan

4th Edition

0138102104, 978-0138102104

More Books

Students also viewed these Databases questions