if(choice != OPEN && openBank == false && choice !=CLOSEACCOUNT && choice != EXIT)
{cout <<"\tPlease, open the account first\n";choice = OPEN;}
//////////////////////Command
switch(choice)
{
//////////////////////////////////////////////////////////////////////////////////////////////////////
case OPEN :
if(openBank == false){
cout <<"\tAccount name : ";cin >> name;openBank = true;balance = 0;
cout <<"\tWell done " << name << "! The Bank System has been opened !!!\n";
}
else
{cout <<"\tYou'll need to close the account first !\n";choice = CLOSEACCOUNT;goto Case;}
break;
//////////////////////////////////////////////////////////////////////////////////////////////////////
case DEPOSIT : d = 0;
cout <<"\tEnter the amount to deposit (min 500) : ";
cin >> d;
while(d < 500)
{
cout <<"\tYou enter is below the minimum deposit. Please enter again.\n\n";
cin >> d;
cout <<"\tEnter the amout to withdraw : ";
cin >> d;
while(d > balance || d<=0 || balance - d < 500){
cout <<"\t Please enter again.\n\n";
cin>>d;
}
balance = balance - d;
break;
//////////////////////////////////////////////////////////////////////////////////////////////////////
case BALANCE :
cout<<"\tYour current balance is: "<<balance<<"\n";
cout <<"Please enter to go back to the main menu. ";getch();
break;
//////////////////////////////////////////////////////////////////////////////////////////////////////
case CLOSEACCOUNT :
if(openBank == false)cout <<"The bank is closed. No need to close now.\n\n";
else
{
cout <<"Please [1] to delete Account and [0] to go back to main menu: "; cin >> choice;
if(choice == 1){name[0] = 0;openBank = false;}
}
break;
//////////////////////////////////////////////////////////////////////////////////////////////////////
case EXIT : bQuit = true; break;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////End case commands
}
//////////////////////End Bank loop
return 0;
}
//////////////////////End program...
It's awful code. No modern C++ compiler will know what to do with it. It uses C++ code from before 1998, when C++ wasn't formalised and it was basically just whatever you could trick a compiler into accepting.
Do not try to learn from such awful, awful code...
Unless you're stuck using a compiler from 20 years ago? Let me guess, Turbo C++ of some kind? What is the deal with people being taught just plain incorrect C++, badly, using old old tools, when there are free modern tools available?
That was my guess, too. But I would have thought that if one was going to cheat on one's homework by copying someone else's work, one would at least have the sense to copy code that wasn't awful.
*Sigh* that's the problem with the world these days - the cheaters have no standards any more.
thank you , it runs online but coudn't deposit , it shows enter again ,,,,,,,,
**i am in the 10th grade and i am taking CS course and our teacher said we can submit any codes as a beginner project, so i came up with ATM or banking system code ideas , and was looking online ,ofcourse i will put this website/forum as a reference, /he said so/ not Plagiarism or copying
@tommy251 did a brief run check of Thomas' few changes and Deposit seems to be fine. If you made further changes you should post your latest as another reply, with [code][/code] tags
Also, if you're going to copy, be ready to defend every single line. Be ready to explain your reasoning behind why the line is there, including type(s) chosen, logic benefits, and, to be honest, I'd be curious to see your defense of some of the indentation.
Withdraw functionality is quite simple.
First you check if the balance is >= withdraw amount. If it is then subtract the amount from the balance otherwise show an error msg.