Apr 22, 2012 at 9:46pm UTC
I have this assigment to do for a beginners programing course but I have a problem. this is my code here:
#include <iostream>
using namespace std;
int main()
{
cout <<"=========================================" << endl;
cout << "WELCOME to MYBANK ATM" << endl;
cout << "========================================" << endl << endl;
cout << "How can I help you today?" << endl << endl;
cout << "Main Menu" << endl <<endl;
cout << "1) Deposit" << endl;
cout << "2) Withdraw" << endl;
cout << "3) Transfer" << endl;
cout << "4) View Balance" << endl;
cout << "5) EXIT" << endl << endl;
{ double xin;
cout << "For Deposit Press 1 then Enter" << endl;
cout << "For Withdraw Press 2 then Enter" << endl;
cout << "For Transfer Press 3 then Enter" << endl;
cout << "For View Balance Press 4 then Enter" << endl;
cout << "To Exit Press 5 then Enter" << endl;
cin>> xin;
while (xin !=5)
{
if (xin ==1)
{
cout << "===================================" << endl;
cout << "Deposit Section of the ATM Software" << endl;
cout << "===================================" << endl << endl;
cout << "Main Menu" << endl <<endl;
cout << "1) Deposit" << endl;
cout << "2) Withdraw" << endl;
cout << "3) Transfer" << endl;
cout << "4) View Balance" << endl;
cout << "5) EXIT" << endl << endl;
cout << "For Deposit Press 1 then Enter" << endl;
cout << "For Withdraw Press 2 then Enter" << endl;
cout << "For Transfer Press 3 then Enter" << endl;
cout << "For View Balance Press 4 then Enter" << endl;
cout << "To Exit Press 5 then Enter" << endl;
cin>> xin;
}
if (xin ==2)
{
cout << "====================================" << endl;
cout << "Withdraw Section of the ATM Software" << endl;
cout << "====================================" << endl << endl;
cout << "Main Menu" << endl <<endl;
cout << "1) Deposit" << endl;
cout << "2) Withdraw" << endl;
cout << "3) Transfer" << endl;
cout << "4) View Balance" << endl;
cout << "5) EXIT" << endl << endl;
cout << "For Deposit Press 1 then Enter" << endl;
cout << "For Withdraw Press 2 then Enter" << endl;
cout << "For Transfer Press 3 then Enter" << endl;
cout << "For View Balance Press 4 then Enter" << endl;
cout << "To Exit Press 5 then Enter" << endl;
cin>> xin;
}
if ( xin ==3)
{
cout << "====================================" << endl;
cout << "Transfer Section of the ATM Software" << endl;
cout << "====================================" << endl << endl;
cout << "Main Menu" << endl <<endl;
cout << "1) Deposit" << endl;
cout << "2) Withdraw" << endl;
cout << "3) Transfer" << endl;
cout << "4) View Balance" << endl;
cout << "5) EXIT" << endl << endl;
cout << "For Deposit Prees 1 then Enter" << endl;
cout << "For Withdraw Press 2 then Enter" << endl;
cout << "For Transfer Press 3 then Enter" << endl;
cout << "For View Balance Press 4 then Enter" << endl;
cout << "To Exit Press 5 then Enter" << endl;
cin>> xin;
}
if ( xin ==4)
{
cout << "========================================" << endl;
cout << "View Balance Section of the ATM Software" << endl;
cout << "========================================" << endl <<endl;
cout << "Main Menu" << endl <<endl;
cout << "1) Deposit" << endl;
cout << "2) Withdraw" << endl;
cout << "3) Transfer" << endl;
cout << "4) View Balance" << endl;
cout << "5) EXIT" << endl << endl;
cout << "For Deposit Press 1 then Enter" << endl;
cout << "For Withdraw Press 2 then Enter" << endl;
cout << "For Transfer Press 3 then Enter" << endl;
cout << "For View Balance Press 4 then Enter" << endl;
cout << "To Exit Press 5 then Enter" << endl;
cin>> xin;
}
if ( xin ==5)
{
cout << "===================================" << endl;
cout << "Exiting from the ATM Sofware" << endl;
cout << "===================================" << endl << endl;
cout << "GOOD BYE!" << endl;
cin>> xin;
}
else
{
cout << "===================================" << endl;
cout << "Invalid Entry!" << endl;
cout << "===================================" << endl << endl;
cout << "Main Menu" << endl <<endl;
cout << "1) Deposit" << endl;
cout << "2) Withdraw" << endl;
cout << "3) Transfer" << endl;
cout << "4) View Balance" << endl;
cout << "5) EXIT" << endl << endl;
cout << "For Deposit Press 1 then Enter" << endl;
cout << "For Withdraw Press 2 then Enter" << endl;
cout << "For Transfer Press 3 then Enter" << endl;
cout << "For View Balance Press 4 then Enter" << endl;
cout << "To Exit Press 5 then Enter" << endl;
cin>> xin;
}
}
system("pause");
return 0;
}
}
However, when option 5 is selected I can not get the program to display the message. Can someone please tell me what I am doing wrong. everything else works flawlessley
Apr 22, 2012 at 10:05pm UTC
Try to use a switch statement. And use code tags please. Also removing the system pause is a step in the right direction.