Program to tell you how many months it will take to pay off

Assignment Help C/C++ Programming
Reference no: EM13162275

 write a program to tell you how many months it will take to pay off any loan, as well as the total amount of interest paid over the life of the loan.

 

For example you have just purchased a stereo system that costs $1000 on the following credit plan: No down payment, an interest rate of 18% per year (and hence 1.5% per month), and monthly payments of $50. The monthly payment of $50 is used to pay the interest and whatever is left is used to pay part of the remaining debt. Hence, the first month you pay 1.5% of $1000 in interest. That is $15 in interest. So, the remaining $35 is deducted from your debt which leaves you with a debt of $965.00. The next month you pay interest of 1.5% of $965.00, which is $14.48. Hence, you can deduct $35.52 (which is $50 - $14.48) from the amount you owe.

 

Write a program that will tell you how many months it will take you to pay off any loan, as well as the total amount of interest paid over the life of the loan. Use a loop to calculate the amount of interest and the size of the debt after each month. Put out the monthly amount of interest paid and remaining debt. Use a variable to count the number of loop iterations and hence the number of months until the debt is zero. You may want to use other variables as well:

 

heres what i have done, How do i fix it?

 

//declaring the variables

double totalLoan,

balanceRemaining,

principal,

month,

annualPercentage,

monthlyPayment,

monthlyInterest,

interestPaid,

principalPaid;

 

cout <<setprecision(2)<<fixed;

cout <<"What is the amount of the loan?";

cin >> totalLoan;

while (totalLoan < 0)

{

cout <<"Invalid entry. Please enter a positive value only";

cin >> totalLoan;

}

cout <<"What is the annual percentage rate?";

cin >> annualPercentage;

while (annualPercentage < 0)

{

cout <<"Invalid entry. Please enter a positive value only";

cin >> annualPercentage;

}

cout << "Enter your monthly payment: "<<endl;

cin >> monthlyPayment;

cout <<endl;

cout <<endl;

cout <<"Month"<<setw(15)<<"Principal"<<setw(13)<<"Interest"<<setw(13)<<"Principal"<<setw(13)<<"Remaining";

cout <<setw(50)<<"paid"<<setw(12)<<"paid"<<setw(17)<<"Balance\n";

monthlyInterest = (annualPercentage/(12*100));

 

for (month = totalLoan; month >=0; ++month)

{

interestPaid= monthlyInterest*totalLoan;

principalPaid= monthlyPayment-interestPaid;

balanceRemaining=totalLoan-principalPaid;

principal=balanceRemaining+principalPaid;

cout <<month<<setw(15)<<principal<<setw(13)<<interestPaid<<setw(13)<<principalPaid<<setw(13)<<balanceRemaining;

 

}

 

 

getch();

 

}

 

 

Reference no: EM13162275

Questions Cloud

How does the hammond postulate explain : the fact that the relative reactivity of C-H bonds of an alkane for free-radical chain halogenation is tertiary > secondary > primary?
What volume would the gas occupy at the same temperature : A 31 L tank contains a gas under a pressure of 617 atm. What volume would the gas occupy at the same temperature at 900 torr of pressure? Answer in units of L.
How many grams of acetic acid are in vinegar : If 3.50ml of vinegar needs 42.0ml of 0.130M NaOH to reach the equivalence point in a titration, how many grams of acetic acid are in a 1.20qt sample of this vinegar?
The most stable form of bromine under standard conditions : The most stable form of bromine under standard conditions is as the diatomic molecule
Program to tell you how many months it will take to pay off : write a program to tell you how many months it will take to pay off any loan, as well as the total amount of interest paid over the life of the loan.
Compute the molar mass of maltose : Calculate the molar mass of maltose (which is not an ionic compound). (b) The density of the solution is 1.014 g/mL. Calculate the osmotic pressure of the solution.
Explain what is the total vapor pressure over the solution : A solution is made by adding 50.0 mL of ethanol (C2H5OH, d = 0.789 g/mL) to 50.0 mL of water (d = 0.998g/mL). What is the total vapor pressure over the solution
Write a function named largest which will receive the array : Write a function named largest which will receive the array as input and return the variable LargestNumber.
Nitrogen dioxide react with water to produce nitric acid : Nitrogen dioxide and water react to produce nitric acid HNO3 and nitrogen monoxide.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Prepare a linear support vector machine svm

Write a computer program to prepare a Linear Support Vector Machine SVM

  Write a menu-driven program that maintains an address book

Write a menu-driven program that maintains an address book using a linked list. The address book must supports the following operations

  Write program function prompt user for number of elements

Write a C++ program main function which will prompt the user for the number of elements called N desired for an array which has the capacity to store 50 elements.

  Make a game in which you guess a number

Make a game in which you guess a number between two set numbers to find the answer, the game should tell you if you are too low in your guess or too high. For example

  Write a driver program called testrationalnumber.cpp

Write a driver program called testRationalNumber.cpp to test each of the above functions and overloaded operators in the RationalNumber class.

  Write a program that asks the user to enter the names of 3

Write a program that asks the user to enter the names of three salesmen. The program should thenaccept the sales produced for salesman for each quarter of the year. Display the name, and the totalsales amount, of each salesman.

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Write c program to accept inputs from user

Write down simple c program which accepts following inputs from user that is username and password, it must ask user what he will like to learn today and also ask user to enter char m=math , e= English.

  Write a full program that implements the aggregation concept

Write a full program that implements the aggregation concept for the Mail Message, Header , Body and Attachment classes.

  Insert the missing code in the c program

You are to insert the missing code in the C program given for combinational equivalence checking. This program will interface with the CUDD package and will parse netlist files in ISCAS85 circuit format. Next, BDDs will be created for each circuit an..

  Make 2-dimensional array

make 2-dimensional array a bit of life and bringing them from the abstract to the concrete realms

  Function odd_fill() that fills all integers between two poin

write a function odd_fill() that fills all integers between two pointers, first and last, with a sequence of odd integers: 1,3,5,7

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd