Monday, April 27, 2020

C++ Challenge #5 | Bank Management System Part (2/3) (Interview Preparat...







source code:



// Bank Management system

// requirements

// 1) Deposite money

// 2) withdraw money

// 3) balance

// 4) transfer

// 5) program exit



#include <iostream>

using namespace std;

int totalamount = 500;



int deposite_amount;

int withdraw_amount;

int transfer_amount;

void deposite(){

cout << "Enter the amount you want to deposite" <<endl;

cin >> deposite_amount;

totalamount += deposite_amount;

cout << "payment has been deposite" <<endl;

}

void withdraw(){

cout << "Enter the amount you want to withdraw" <<endl;

cin >> withdraw_amount;

totalamount -= withdraw_amount;

cout << "payment has been withdrawn";

}

void balance(){

cout << "total amount " << totalamount;

}

void transfer(){

cout << "Enter the amount you want to transfer" <<endl;

cin >> transfer_amount;

totalamount -= transfer_amount;

cout << "payment has been transfered";

}

main(){

char ch;

do{

int choice;

cout << "Press 1 for deposite money" <<endl;

cout << "Press 2 for withdraw money" <<endl;

cout << "Press 3 for check balance" <<endl;

cout << "Press 4 for transfer money" <<endl;

cout << "Press 5 to exit the program" <<endl;



cout << "Enter your choice" <<endl;

cin >> choice;



switch(choice){

case 1:

deposite();

break;

case 2:

withdraw();

break;

case 3:

balance();

break;

case 4:

transfer();

break;

case 5:

exit(0);

break;

default:

cout << "Invalid input";



}

cout << "Press Y or y to continue program" <<endl;

cin >> ch;





}while(ch == 'Y' || ch == 'y');





}

No comments:

Post a Comment