Hello, I'm new to C++ this year and decided I should take the challenge.
Before you see the code let me explain to you what I'm to be doing.
I have to create a program that asks the user for there name, account number, balance, how much they deposited, and how much they withdrew.
Then it will calculate how much your new balance should be.
Where am i stuck? I don't understand when I run this, after asking me all the questions it will terminate and not show the results of how much I have as my new balance. I hit enter after the last question and the window closes.
Thanks
ok so heres my code..
#include <iostream.h>
using namespace std;
int main ( )
{
char Name [25]; //stores user's name
long Account_Number; //stores user's account number
float statement_balance; //stores user's account balance
float outstanding_deposit; //stores users deposit
float balance, deposit, withdraw, new_balance;
cout << "This Program will tell you your balance in your bank account." ;
cout << "What is your name?";
cin.get (Name,25);
cin.ignore (80,'\n');
cout << "What is your account number?";
cin >> Account_Number;
cout << "What is your account balance?";
cin >> statement_balance;
cout << "How much did you deposit?";
cin >> outstanding_deposit;
cout << "How much did you withdraw?";
cin >> withdraw;
#include <iostream.h>
usingnamespace std;
int main ( )
{
char Name [25]; //stores user's name
long Account_Number; //stores user's account number
float statement_balance; //stores user's account balance
float outstanding_deposit; //stores users deposit
float balance, deposit, withdraw, new_balance;
cout << "This Program will tell you your balance in your bank account." ;
cout << "What is your name?";
cin.get (Name,25);
cin.sync();
cin.ignore (80,'\n');
cout << "What is your account number?";
cin >> Account_Number;
cin.sync();
cout << "What is your account balance?";
cin >> statement_balance;
cin.sync();
cout << "How much did you deposit?";
cin >> outstanding_deposit;
cin.sync();
cout << "How much did you withdraw?";
cin >> withdraw;
cin.sync();
new_balance = (statement_balance + outstanding_deposit) - withdraw;
cout <<"Your balance is " << new_balance << '\n';
cin.get();
return 0;
}
PS: Sorry if anyone gets mad at me for the 'cin.get();' thing, I know 'system("PAUSE"); ' is bad and this is the only other method I know of.