Hi, i know im not supposed to post HW questions but i am out of time and i cant figure my problem out.
My task was to create a ATM menu for deposits and to check my balance. the problem i am having is i can not make my deposits value sum with other vales from previous deposits. Also i do not know how to make the total transcend into another while loop to be displayed in check balance. the equation is from line 36-41 and needs to be displayed on lines 98-101. Please its due at 11 tonight and im just stuck have spent hours getting this far. please help this is my first C++ code.
#include <iostream>
usingnamespace std;
int main(int argc, char * const argv[])
{
{int mainMenu;
cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << endl;
cout<<"welcome to My BAnk ATM"<<endl;
cout<<"Your Friend in the Market"<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<< "How can I Help you Today?"<<endl;
cout<< "1)Deposit Money"<<endl;
cout<< "2)Check Balance"<<endl;
cout<< "3)Nothing, Exit"<<endl;
cin>>mainMenu;
while (mainMenu !=3)
{
if (mainMenu==1)
{
cout<<"Thank you for Depositing Funds Today"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
int depositeMenu;
cin>>depositeMenu;
while(depositeMenu !=3)
{
if(depositeMenu==1)
{
{
double checkingAcc;
double mydollar;
mydollar=0;
cout<<"please enter dollar amount to be deposited into checking"<<endl;
{ cin>> mydollar; cout<<"$";
checkingAcc=checkingAcc+mydollar;}// need to make checkingAcc give accurate results
cout<<"============================================"<<endl;
cout<<"Thank you for Depositing Funds Today"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
cin>> depositeMenu;
cout<<"--------------------------------------------"<<endl;
}
elseif (depositeMenu==2)
{
{
double savingAcc=0;
double mydollar;
mydollar=0;
cout<<"Please enter dollar amount to be deposited into savings"<<endl;
{cin>>mydollar;
savingAcc=savingAcc+mydollar;}
cout<<savingAcc;
}
// need to make savingAcc give accurate results
cout<<"==========================================="<<endl;
cout<<"Thank you for Depositing Funds Today"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
cin>> depositeMenu;
cout<<"--------------------------------------------"<<endl;
}
else
{
cout<<"============================================"<<endl;
cout<<"Invalid Entry, Please Try Again"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
cin>> depositeMenu;
cout<<"--------------------------------------------"<<endl;
}
}
{
cout<< "How can I Help you Today?"<<endl;
cout<< "1)Deposit Money"<<endl;
cout<< "2)Check Balance"<<endl;
cout<< "3)Nothing, Exit"<<endl;
cin>>mainMenu;
}
}
elseif (mainMenu==2)
{
double savingAcc ;
cout<< "Your Saving Balance =" <<cout<< savingAcc <<endl;
double checkingAcc;
cout<<"Your Checking Balance =" <<cout<< checkingAcc <<endl;
cout<<"============================================="<<endl;
cout<<"Please Make A Choice"<<endl;
cout<< "1)Deposit Money"<<endl;
cout<< "2)Check Balance"<<endl;
cout<< "3)Nothing, Exit"<<endl;
cin>>mainMenu;
cout<<"--------------------------------------------"<<endl;
}
else
{
cout<<"invalid Answer, Try Again"<<endl;
cout<< "1)Deposit Money"<<endl;
cout<< "2)Check Balance"<<endl;
cout<< "3)Nothing, Exit"<<endl;
cin>>mainMenu;
}
}}cout<<"===================================="<<endl;
cout<<"Thank you for your business Today"<<endl;
cout<<"Hope to see you sometime soon...Bye."<<endl;
cout<<"====================================" <<endl;
return 0;
}
appreciate the help, makes sense to pull it out so they are included in everything. with the code as is i get this responce for my balance
Your Saving Balance =0xa091d50446
Your Checking Balance =0xa091d50446
=============================================
Please Make A Choice
1)Deposit Money
2)Check Balance
3)Nothing, Exit
#include <iostream>
usingnamespace std;
int main(int argc, char * const argv[])
{
{int mainMenu;
double checkingAcc = 0.0 ;
double savingAcc = 0.0 ;
double mydollar=0.0;
cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << endl;
cout<<"welcome to My BAnk ATM"<<endl;
cout<<"Your Friend in the Market"<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<< "How can I Help you Today?"<<endl;
cout<< "1)Deposit Money"<<endl;
cout<< "2)Check Balance"<<endl;
cout<< "3)Nothing, Exit"<<endl;
cin>>mainMenu;
while (mainMenu !=3)
{
if (mainMenu==1)
{
cout<<"Thank you for Depositing Funds Today"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
int depositeMenu;
cin>>depositeMenu;
while(depositeMenu !=3)
{
if(depositeMenu==1)
{
cout<<"please enter dollar amount to be deposited into checking"<<endl;
cin>> mydollar; cout<<"$";
checkingAcc=checkingAcc+mydollar;
mydollar=0;
cout<<"============================================"<<endl;
cout<<"Thank you for Depositing Funds Today"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
cin>> depositeMenu;
cout<<"--------------------------------------------"<<endl;
}
elseif (depositeMenu==2)
{
cout<<"Please enter dollar amount to be deposited into savings"<<endl;
cin>>mydollar;
savingAcc=savingAcc+mydollar;
mydollar=0;
cout<<savingAcc;
cout<<"==========================================="<<endl;
cout<<"Thank you for Depositing Funds Today"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
cin>> depositeMenu;
cout<<"--------------------------------------------"<<endl;
}
else
{
cout<<"============================================"<<endl;
cout<<"Invalid Entry, Please Try Again"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
cin>> depositeMenu;
cout<<"--------------------------------------------"<<endl;
}
}
{
cout<< "How can I Help you Today?"<<endl;
cout<< "1)Deposit Money"<<endl;
cout<< "2)Check Balance"<<endl;
cout<< "3)Nothing, Exit"<<endl;
cin>>mainMenu;
}
}
elseif (mainMenu==2)
{
cout<< "Your Saving Balance =" <<cout<< savingAcc <<endl;
cout<<"Your Checking Balance =" <<cout<<
checkingAcc <<endl;
cout<<"============================================="<<endl;
cout<<"Please Make A Choice"<<endl;
cout<< "1)Deposit Money"<<endl;
cout<< "2)Check Balance"<<endl;
cout<< "3)Nothing, Exit"<<endl;
cin>>mainMenu;
cout<<"--------------------------------------------"<<endl;
}
else
{
cout<<"invalid Answer, Try Again"<<endl;
cout<< "1)Deposit Money"<<endl;
cout<< "2)Check Balance"<<endl;
cout<< "3)Nothing, Exit"<<endl;
cin>>mainMenu;
}
}}cout<<"===================================="<<endl;
cout<<"Thank you for your business Today"<<endl;
cout<<"Hope to see you sometime soon...Bye."<<endl;
cout<<"====================================" <<endl;
return 0;
}
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
out<<" 3)Back to Main Menu"<<endl;
Can you do anything to avoid the repetition in code?
I would just like to say thanks JLBorges, My assignment is behaving properly now thanks to you.
but i feel if i used the term "for" i could somehow repeat or return to the main menu options. still just trying to understand what exactly "for" does.
You are going to drive your teacher nuts with your spacing/formatting. You don't need to keep indenting farther in if it's all part of the same while statement. Would you want to read that assignment? Go read some example programs off the net or from your book to see how formatting should look.
In case you don't know if you highlight a chunk of your code and press tab it indents to the right and shift + tab indents to the left.
"for" indicates a For loop. These are used when you want to repeat a loop and you know the specific number of times you want it to repeat. I'll let you google more information about how to make them.
So i have decided that the operation "do" should be the best. I have the program set up right i hope. but the code only cycles though the "while" once. i have tried while(statement && statement) to do multiple responses but i cant seem to get the depositMenu to go back to the do statement.
thanks for the question, it was a useful. ill be asking my teacher tomorrow lets hope he can figure it out.
#include <iostream>
usingnamespace std;
int main(int argc, char * const argv[])
{
{int mainMenu;
int depositeMenu;
double checkingAcc = 0.0 ;
double savingAcc = 0.0 ;
double mydollar=0.0;
do
{
cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << endl;
cout<<"welcome to My BAnk ATM"<<endl;
cout<<"Your Friend in the Market"<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<< "How can I Help you Today?"<<endl;
cout<< "1)Deposit Money"<<endl;
cout<< "2)Check Balance"<<endl;
cout<< "3)Nothing, Exit"<<endl;
cin>>mainMenu;
}
while (mainMenu!=1 && mainMenu!=2);
{
if (mainMenu==1)
{
cout<<"============================================"<<endl;
cout<<"Thank you for Depositing Funds Today"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
cin>> depositeMenu;
cout<<"--------------------------------------------"<<endl;
while(depositeMenu!=3);
{
if(depositeMenu==1)
{
cout<<"please enter dollar amount to be deposited into checking"<<endl;
cin>> mydollar; cout<<"$";
checkingAcc=checkingAcc+mydollar;
mydollar=0;
cout<<"============================================"<<endl;
cout<<"Thank you for Depositing Funds Today"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
cin>> depositeMenu;
cout<<"--------------------------------------------"<<endl;
}
elseif (depositeMenu==2)
{
cout<<"Please enter dollar amount to be deposited into savings"<<endl;
cin>>mydollar;
savingAcc=savingAcc+mydollar;
mydollar=0;
cout<<savingAcc;
cout<<"============================================"<<endl;
cout<<"Thank you for Depositing Funds Today"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
cin>> depositeMenu;
cout<<"--------------------------------------------"<<endl;
}
else
{
cout<<"============================================"<<endl;
cout<<"Invalid Entry, Please Try Again"<<endl;
cout<<"Please Make Your Selection"<<endl;
cout<<" 1)Deposit into Checking"<<endl;
cout<<" 2)Deposit into Savings"<<endl;
cout<<" 3)Back to Main Menu"<<endl;
cin>> depositeMenu;
cout<<"--------------------------------------------"<<endl;
}
}
}
elseif (mainMenu==2)
{
cout<< "Your Saving Balance =" << savingAcc <<endl;
cout<<"Your Checking Balance ="<< checkingAcc <<endl;
cout<<"============================================="<<endl;
cout<<"Please Make A Choice"<<endl;
cout<< "1)Deposit Money"<<endl;
cout<< "2)Check Balance"<<endl;
cout<< "3)Nothing, Exit"<<endl;
cin>>mainMenu;
cout<<"--------------------------------------------"<<endl;
}
else
{
cout<<"invalid Answer, Try Again"<<endl;
cout<< "1)Deposit Money"<<endl;
cout<< "2)Check Balance"<<endl;
cout<< "3)Nothing, Exit"<<endl;
cin>>mainMenu;
}
}
}
cout<<"===================================="<<endl;
cout<<"Thank you for your business Today"<<endl;
cout<<"Hope to see you sometime soon...Bye."<<endl;
cout<<"====================================" <<endl;
return 0;
}