-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBankPractise1.cpp
92 lines (75 loc) · 2.02 KB
/
BankPractise1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include<iostream>
#include<iomanip>
#include <limits>
using std::cin;
using std::cout;
using std::string;
void showBalance(double balance);
double deposit(double amount);
double withdraw(double amount);
void dataBase(string name, int ac_No);
int main(){
double balance = 100;
int choice = 0;
do{
cout<<"\n <--===- Banking Application -===-->\n";
cout<<"---- ------------- ----\n";
cout<<" 1 --> Show Balance\n";
cout<<" 2 --> Deposit\n";
cout<<" 3 --> Withdrawl\n";
cout<<" 4 --> Exit\n";
cout<<"\n\nEnter the input Here ==> ";
cin>>choice;
if (cin.fail()) {
cin.clear(); // Clear error flags
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // Clear the input buffer
}
// std::cin.clear();
// fflush(stdin);
switch(choice){
case 1: showBalance(balance);
break;
case 2: balance += deposit(balance);
showBalance(balance);
break;
case 3: balance -= withdraw(balance);
showBalance(balance);
break;
case 4: cout<<"Exited";
break;
default: cout<<"\n=== Enter Valid Choice between 1 - 4 ===\n";
break;
}
}while(choice!=4);
return 0;
}
void showBalance(double myBalance){ //bal func
cout<<"Your Balance is --> "<<std::setprecision(2)<<std::fixed<<myBalance <<"\n";
};
double deposit(double myBalance){
double amount = 0;
cout<<"Please enter the amount for Deposit ==> ";
cin>>amount;
if(amount<0){
cout<<"\nEnter the Valid Amount\n";
return 0;
}
else {
return amount;
}
}
double withdraw(double myBalance){
int amount;
cout<<"Please enter the anount for Withdrawl ==> ";
cin>>amount;
if(amount<0){
cout<<"\nEnter the valid Amount\n";
}
else{
return amount;
}
return 0;
}
// void dataBase(string name[], int ac_No){
// name[] =
// }