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

  Write c program-visual studio to scan multiple text files

Write program in C or C++ and Visual Studio to scan multiple text files and count number of occurrences of each word in those files. Use binary tree to keep track of all words.

  Write c program for linked list applications

Write a complete C program which illustrates the Linked list applications data structures and algorithms. The program will read in mid-semester test scores as Main Linked List and produce six outputs:

  Three or more dimensions

What kind of program, or problem, might necessitate arrays of three or more dimensions?

  Multiple heaps

Create an application that has two heaps. Place a linked list into each heap. Select one hundred random numbers. Place each of the random numbers into each heap - CSI 345 - Spring 2014 S2

  Design a deck plan space ship in eclipse

Develop a simple interactive two-dimensional spaceship deck plan editor using OpenGL and GLUT. Your program will enable a user to create and save a deck plan of a hypothetical spaceship comprising the hull walls.

  Create a text file named grades.txt

Write a program to calculate students' average test scores and their grades. Creat a text file named  grades.txt

  Write c program that forks two child processes

Write a C program that forks two child processes. The parent process will print all prime numbers up to 229, the first child process will print the first 50 Fibonacci numbers.

  Include the iostream, fstream, string, and cctype libraries

1. Include the iostream, fstream, string, and cctype libraries in your program.

  Calculate the net pay as the gross less the taxes

Design and code a new function that accepts as parameters the gross pay by value and the federal tax, state tax, local tax, SS tax, and net Pay by reference.

  Maze program

Maze program. In this assignment you will represent a maze with a binary tree. . The starting point is node N and the ending point is node Z.

  Develop a basic temperature class

You have to develop a basic temperature class

  Design and write a c++11/fltk game program

The project is to design and write a C++11/FLTK game program with a graphical user interface. The game is based on "pancake sorting," which actually has some mathematical significance.

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