Question about a loan calculator

Hello everyone, I'm trying to build an interactive loan calculator for a school project. These are the requirements:

Your program should do the following:
•Display a Welcome title for the Loan Calculator
•Prompt the user to enter the price of the car
•Prompt the user to enter the length of the term in months
•Prompt the user to enter the APR in percentage (e.g. 4.79%) - without the percent sign of course

Your program should then report with the monthly payment will be.

Use setw() and setfill() to display the content like a receipt. All the data should be neatly displayed.

Example

For a Friend Loan Calculator

Price of Vehicle: $25,000
Term of Loan (in months): 60
APR in percentage (e.g. 4.79% - without the percent sign): 3.8
--------------------------------------------------------------
Total Monthly Payments: $433.50 //NOT ACCURATE

Display all money totals (output values) to two decimal places. You should output an accurate result as well.

For extra credit you may factor in a state auto sales tax of 6.5% of the purchase price of the vehicle and how much of a down payment the user would like to put down. Of course, if you are factor down payment, you must prompt the user to enter that amount.

I attempted to build one but I'm getting a lot of errors using Microsoft visual studio. If anyone could help show me where I need to make changes that would be greatly appreciated! Here it is below:

/*

My Name
Interactive Loan Calculator
C++

*/




#include <iostream>
#include <cmath>
#include <ctime>
#include <cstdlib>
using namespace std;


int num1,
num2,
response,
answer1,
ran1,
x;

int main()
{
cout << "Welcome to my Interactive Loan Calculator"<<endl;
cout <<"By My name"<<endl;
cout <<"This program will input basic information about your loan"<<endl;
cout <<"It will output what your monthly payment will be"<<endl;
cout <<endl;
float loanamount;
float interestrate;
float monthlypayment;
cout <<"What is the amount of the loan?$";
cin >>loanamount; cin.ignore();
cout << What is the interest rate on the loan?$";
cin >>interestrate;interestrate/=100;cin.ignore();
cout <<"What is the desired monthly payment?$";
cin >>monthlypayment;cin.ignore();

while(monthlypayment<loanamount*interestrate/12){
cout <<"Not a valid payment amount. Amount must be greater than$";
cout <<(loanamount*interestrate/12)<<endl;
cout <<"What is the desired monthly payment amount?$";
cin >>monthlypayment:cin.ignore();
}

float totalpaid=0.0f;
floatinteresttoadd=0.0f;
int nmonths=0;
float remaining=loanamount;
float toadd=0.0f;
cout << Month# Interest /added, Amount Paid, Debt Remaining"<<endl;
while(remaining>0){
interesttoadd=remaining*interestrate/12;
nmonths++;
remaining+=interesttoadd;
if(remaining>monthlypayment){
toadd=monthlypayment;
}else
toadd=remaining;
}
cout<<nmonths<<":$"<<interesttoadd<<":$"<<toadd
<<":$"<<remaining<<endl;
totalpaid+=toadd;
remaining-=toadd;
}
cout <<endl<<"Statistics aout loan."<<endl;
cout <<"Initial loan amount:$"<<loanamount<<endl;
cout <<"Total amount paid:$"<<totalpaid<<endl;
cout <<"Time to pay off loan:"<<nmonths<<endl;
cout <<"Overpay percentage:"<<(totalpaid/loanamount)<<endl;
cout <<"Press enter to exit program..."<endl;
cin.ignore();
return0;
}
When posting code use code tags
[code][/code]

What errors are you getting?
missing opening double quotes
cout << What is the interest rate on the loan?$";

should be a ; not a :
cin >>monthlypayment:cin.ignore();

need a space between the type and the variable name
floatinteresttoadd=0.0f;

missing opening double quotes
cout << Month# Interest /added, Amount Paid, Debt Remaining"<<endl;

missing opening { for the else block
1
2
3
}else
toadd=remaining;
}


missing second < before endl
cout <<"Press enter to exit program..."<endl;

need space between return and 0
return0;
Last edited on
Thank you everyone for all your help! I finally got it working.
Topic archived. No new replies allowed.