I'm trying to help a friend out with a program he's working on, but we're getting weird errors-after typing "Return" it closes randomly instead of reiterating the loop.
#include <iostream>
#include <conio.h>
//Make a program that simulates an ATM that will continue until you run out of money.
//Make two variables, one for dollars and one for cents.
//Make three buyable items...
//You start with $10.00 plus a random number of dollars and cents
usingnamespace std;
float cash = 10.00;
//char atm[128];
string atm;
bool mainmenu = false;
int main (){
cout.setf(ios::showpoint);
cout.precision(4);
cout << "Welcome to THE Cash Register.\nType Return at anytime to return to the main menu.\n\n";
while(1){
cout << "What would you like to do?\n\nView Balance\nWithdraw\nDeposit\nRob the ATM\n\n";
getline(cin, atm);
if(!strcmp(atm.c_str(),"Withdraw")){
cout << "\nHow much would you like to withdraw?\nYou can only withdraw in $1.00 increments.\n\n";
//Figure out how to define a wanted withdrawal amount/int(?) and make error message if>int cash.
float withdrawamount;
cin >> withdrawamount;
if(withdrawamount>cash)
cout << "Blaahh wrongg blahahahh\n\n";
else{
cout.precision(3);
cash -= withdrawamount;
cout << "Withdrawal succeeded.\nCurrent Balance: " << cash << "\n\n";
}
getline(cin, atm);
if(!strcmp(atm.c_str(),"Return"))
{
system("cls");
continue;
}
}
elseif(!strcmp(atm.c_str(),"View Balance")){
cout << "\nCurrent Balance: " << cash << "\n\n";
getline(cin, atm);
if(!strcmp(atm.c_str(),"Return")){
system("cls");
continue;
}
}
getch();
return 0;
}
}