The correction is here:
Code:
#include<iostream>
using namespace std;
int main(){
int accounttype;
int totalamount;
int minimbalance;
int currentbalance;
int accountnumber;
cout << "Choose from the followings, 1 for savings 2 for checkings: ";
cin >> accounttype;
cout << "Enter your minimum balance: ";
cin >> minimbalance;
cout << "Enter your current balance: ";
cin >> currentbalance;
cout << "What is your account number? \nPlease enter your account number: " ;
cin >> accountnumber;
if (accounttype == 1)
{
if (currentbalance < minimbalance)
totalamount = currentbalance - 10;
else
{
if (currentbalance >= minimbalance)
totalamount = currentbalance * 1.04;
}
}
else
{
if (accounttype == 2)
{
if (currentbalance < minimbalance)
totalamount = currentbalance - 25;
else
{
if (currentbalance >= minimbalance && currentbalance >= 5000)
totalamount = currentbalance * 1.05 ;
else
{
if (currentbalance < minimbalance && currentbalance <= 5000)
totalamount = currentbalance * 1.03;
}
}
}
}
cout << "Your account type is " << accounttype << endl;
cout << "Your account number is " << accountnumber << endl;
cout << "Your current balance which is your total balance is: " << totalamount << endl;
return 0;
}
Your last code improved greatly, however, you still do many sintax errors (less than before) and logical errors. Check carefully this code i provided and see the changes.
Now some tips:
Try to think about what you need to do step by step, your first error was the variable declarations, you never used accounttype, so in the end it will generate an error because the variable was never initialized.
You used 'select' variable, why? it just doesn't do anything, you need to input the account type directly to 'accounttype' variable.
The conditions were incorrect, first you need to check what accounttype was selected, if was 1, do what you want, else (anything exept 1) if accounttype is 2 then do what you need to do. Always think carefully then you're making conditions.
Another error i realised was 'currentbalance < minimbalance && <= 5000', well, your idea was correct but the sintax not, the language needs to know what value is <= 5000, so i corrected that in this way 'currentbalance < minimbalance && currentbalance <= 5000'.
And thats all
