Sunday, August 24, 2014

Bank Account Project C++

// Bank_Accout.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <conio.h>

using namespace std;

class BankAccount{
private:
int x;
int balance;
public:
void withdraw(){
cout<<"Enter the amount you want to withdraw: ";
cin >> x;
balance-=x;
cout<< "Your remaining balance is: "<<balance;
}

void deposit(){
cout<<"Enter the amount you want to deposit: ";
cin >> x;
balance+=x;
cout<< "Your new balance is: "<<balance;
}

void showBalance(){
cout<< "Your current balance is: "<<balance;
}

BankAccount(){
cout<<"Enter the amount in the account: ";
cin>>balance;
}
};

int _tmain(int argc, _TCHAR* argv[])
{
BankAccount a;
int n;

cout<< "Enter your choice: \n1: Withdraw amount\n2: Desposit amount\n3: Check Balance";
cin >> n;

while(n!='e'){

cout<< "Enter your choice: \n1: Withdraw amount\n2: Desposit amount\nCheck Balance";
cin >> n;

switch (n){
case 1:
a.withdraw();
break;
case 2:
a.deposit();
break;
case 3:
a.showBalance();
break;
default:
cout<< "Enter a valid option\n";

}

}
_getch();
return 0;
}

No comments:

Post a Comment