I'm having a problem with infinite looping of my code. i am new to C++ and am writing a mortgage calculator for school assignment and my instructor is of no help. I ran across the faq/chap 15 on <iostream> and attempted to input the example within my code and receive nothing but error messages since...Can someone point out to me what I'm doing wrong PLEASE.
the errors i'm receiving are as follows:
...er.cpp(25): error C2059: syntax error : '{'
...er.cpp(25): error C2143: syntax error : missing ';' before '{'
...er.cpp(59): fatal error C1075: end of file found before the left brace '{' at 'c:\users\charl es i. clay\desktop\pr g 410\er\er\er.cp p(13)' was matched
1>
1>Build FAILED.
I am completely lost as i've gone over it a million times.
Code:
/*Header Section*/ #include "stdafx.h" #include <iostream> #include <math.h> #include <limits> using namespace std; /*End Header Section*/ int _tmain(int argc, _TCHAR* argv[]) { double LoanAmount ; double InterestRate ; double TermInMonths ; int i = 0 ; int Years; int quit = 0; do { // input loan amount while ((std::cout << "Enter Loan amount without decimals: ") && (!(std::cin >> i) || i < 1 || i > 999999999)); } { std::cout << "That's not a number between 1 and 999999999; "; std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // input interest rate cout << "Enter interest rate(%): (Format 5.70 for 5.70%) " ; cin >> InterestRate; // input mortgage term cout << "Enter terms of mortgage in years: "; cin >> Years; InterestRate = InterestRate / 100 ; TermInMonths = Years * 12 ; // monthly payment calculation formula double payment = LoanAmount * (( InterestRate/12)/(1-pow( 1 / ( ( 1 + InterestRate / 12 ) ) , TermInMonths ) ) ); cout << "\nLoan Amount:\t$" << LoanAmount << endl; cout << "Interest Rate:\t" << InterestRate*100 << "%" << endl; cout << "Terms in Months:\t" << TermInMonths << endl; // display the payment amount cout << "Monthly Payment:\t$" << payment << endl; cout << "\n1. Enter new data" << endl; cout << "2. Quit" << endl; cout << "Select a choice: "; cin >> quit; while ( quit != 2 ); return 0; }
...er.cpp(25): error C2059: syntax error : '{'
...er.cpp(25): error C2143: syntax error : missing ';' before '{'
...er.cpp(59): fatal error C1075: end of file found before the left brace '{' at 'c:\users\charl es i. clay\desktop\pr g 410\er\er\er.cp p(13)' was matched
1>
1>Build FAILED.
I am completely lost as i've gone over it a million times.
Comment