mini project on bank account by oop.;
E.balagurusamy 5.1 solution
#include<bits/stdc++.h>
#include<conio.h>
using namespace std;
class account
{
string name;
int ac_number;
string type_ac;
double amount;
public :
void assign_val()
{
system("cls");
cout<<"Enter your name : ";
cin>>name;
cout<<"Enter your account number : ";
cin>>ac_number;
cout<<"Enter your account type : ";
cin>>type_ac;
cout<<"Enter initial amount : ";
cin>>amount;
system("cls");
cout<<"\nacount create successfully \n\n";
cout<<"press any key to go main manu : ";
getch();
}
void deposit()
{
system("cls");
int ac;
cout<<"Enter account number : ";
cin>>ac;
if(ac==ac_number)
{
double am;
cout<<"Enter amount : ";
cin>>am;
amount+=am;
}
else cout<<"Invalid account number\n";
cout<<"press any key to go main manu : ";
getch();
}
void display1()
{
system("cls");
int ac;
cout<<"Enter account number : ";
cin>>ac;
if(ac==ac_number)
{
cout<<"Your name : "<<name<<endl;
cout<<"Your balance : "<<amount<<endl;
}
else cout<<"Invalid account number\n";
cout<<"press any key to go main manu : ";
getch();
}
void display()
{
system("cls");
cout<<"Your name : "<<name<<endl;
cout<<"Your balance : "<<amount<<endl;
cout<<"press any key to withdraw : ";
getch();
}
void withdraw()
{
system("cls");
int ac;
cout<<"Enter account number : ";
cin>>ac;
if(ac==ac_number)
{
display();
system("cls");
double am;
cout<<"Enter amount : ";
cin>>am;
if(am<=amount)
{
cout<<"Withdraw amount : "<<am<<endl;
}
else cout<<"Sorry!!! insuficient balance : ";
}
else cout<<"Invalid account number\n";
cout<<"press any key to go main manu : ";
getch();
}
};
int main()
{
account person1;
while(1)
{
system("cls");
int choose;
cout<<"1.create account\n2.log in\n";
cout<<"Enter choose : ";
cin>>choose;
if(choose==1)
{
person1.assign_val();
}
else
{
system("cls");
int chose;
cout<<"1.Deposit\n2.Withdraw\n3.Display name and balance \n";
cout<<"Enter choose : ";
cin>>chose;
if(chose==1)
{
person1.deposit();
}
else if(chose==2) person1.withdraw();
else if(chose==3)person1.display1();
else cout<<"Invalid choose\n";
}
}
return 0;
}
0 Comments