So, I haven't used C++ in a while and I want to get back into it and learn more.
I wrote a simple program to set up the balance of a bank account, and then withdraw an amount and display the final balance, then close.
Now I took this program, and added the option of a second transaction, It ignores whether the strings are Y or N and goes through the entire program.
Anyone care to help?
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{
float balance;
int x;
string y;
cout << "What is your balance? \n";
cin >> balance;
cout << "How much do you wish to withdraw? \n";
cin >> x;
balance = balance - x;
cout << "Your new balance is ";
cout << balance;
cout << "\n";
cout << "Do you wish to complete another transaction? (Y or N) \n";
cin >> y;
if (y == "Y");
{
string b;
cout << "Do you wish to deposit this time? (Y or N) \n";
cin >> b;
if (b == "N");
{
cout << "How much do you wish to withdraw?\n";
cin >> x;
balance = balance - x;
cout << "Your new balance is";
cout << balance;
}
if (b == "Y");
{
cout << "How much do you wish to deposit?\n";
cin >> x;
cout << "\n Your new balance is \n";
cout << balance;
system("pause");
return(0);
}
}
if (y == "N");
{