Have an error and dont know what to do
Write your question here.
I keep getting an error at 41/01 saying i need a ";" before "{"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include<iostream>
using namespace std;
int main()
{
int accNumber;
double begBal,
totalCharge,
totalCredits,
creditLimit,
newBalance;
string name;
cout <<"Enter account number (or -1 to quit): " << endl;
cin >> accNumber;
while (accNumber != - 1)
{
cout <<"Enter customer name: " << endl;
cin >> name;
cout <<"Enter beginning balance: " << endl;
cin >> begBal;
cout <<"Enter total credits this month: " << endl;
cin >> totalCredits;
cout <<"Enter total charges this month; " << endl;
cin >> totalCharge;
cout <<"Enter credit limit: " << endl;
cin >> creditLimit;
newBalance = (begBal + totalCharge - totalCredits);
if (newBalance > creditLimit)
{
cout <<"New balance " << newBalance << endl;
cout <<"Credit Limit Exceeded" << endl;
}
else (newBalance < creditLimit)
{
cout <<"New Balance " << newBalance << endl;
cout <<"There is an available balance" << endl;
}
}
return 0;
}
|
Last edited on
you are using string so you need to include the string header file.
1 2 3 4 5 6 7 8 9 10
|
if (newBalance > creditLimit)
{
cout <<"New balance " << newBalance << endl;
cout <<"Credit Limit Exceeded" << endl;
}
else (newBalance < creditLimit)
{
cout <<"New Balance " << newBalance << endl;
cout <<"There is an available balance" << endl;
}
|
the else should be an else if statement.
1 2
|
cout <<"Enter account number (or -1 to quit): " << endl;
cin >> accNumber;
|
this should be included at the end of your loop to give the user an option to exit the loop. Otherwise you have an infinite loop.
What do you mean by else if statement?
1 2 3 4 5
|
else if(newBalance < creditLimit)
{
cout <<"New Balance " << newBalance << endl;
cout <<"There is an available balance" << endl;
}
|
thanks for your help idk what motivate you to help people like this but you saved me 50 dollars lol tutors are expensive
Topic archived. No new replies allowed.