0% found this document useful (0 votes)
80 views6 pages

INHERIT5

The document contains C++ code to create a banking application with classes for account holder, savings account, and current account. The code allows a user to create an account, make transactions like deposit, withdraw, check balance. It also has input/output examples showing sample user interactions like creating a joint savings account, making deposits and withdrawals, and displaying the account details.

Uploaded by

Shenbaga Vengat
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views6 pages

INHERIT5

The document contains C++ code to create a banking application with classes for account holder, savings account, and current account. The code allows a user to create an account, make transactions like deposit, withdraw, check balance. It also has input/output examples showing sample user interactions like creating a joint savings account, making deposits and withdrawals, and displaying the account details.

Uploaded by

Shenbaga Vengat
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PROGRAM CODING:

#include<iostream.h> #include<conio.h> #include<string.h> static count; class accholder { public: int accno,balance,phno,credit,debit; char name[20],add[50],acctyp[30]; public: accholder() { accno=0; balance=0; credit=0; debit=0; } void getdetails() { count+=1; accno=count; cout<<"\nAccount No : "<<accno; cout<<"\nEnter account holder name"; cin>>name; cout<<"Enter address"; cin>>add; cout<<"Enter contact no"; cin>>phno; } void transaction() { cout<<"Enter amount to be withdrawn"; cin>>debit; balance-=debit; cout<<"Amount withdrawn\n Current balance: "<<balance; } void deposit(int amt) { balance+=amt; cout<<"Amount deposited\n Current balance: "<<balance; } void checkbal() { float intrest; int ri=4,yr=1; cout<<"Enter no of years"; cin>>yr; intrest=((balance*yr*ri)/100); balance+=intrest; cout<<"Interest: "<<intrest; cout<<"Current Balance: "<<balance; }

void display() { cout<<"\nWelcome \n"; cout<<"\n\nAccount Holder Name:"<<name; cout<<"\nAccount NO: "<<accno; cout<<"\nAccount type:"<<acctyp; cout<<"\n------------------------------------------------\n"; cout<<"Withdraw\tDeposit\tBalance"; cout<<"\n-------------------------------------------------"; cout<<"\n"<<credit<<"\t"<<debit<<"\t"<<balance<<"\n"; }}; class savings:public accholder { char aname[20]; int ach,acs; public: void getdata() { cout<<"\n\n1.Joint account\n2.Individual"; cin>>ach; if(ach==1) { cout<<"\nEnter additional member name:"; cin>>aname; cout<<"\n1.Both surviver\n2.Either or surviver"; cin>>acs; if(acs==1) strcpy(acctyp,"Savings Joint-both"); else {strcpy(acctyp,"Savings Joint-either or survive"); } cout<<"\nMinimum Balance should be Rs.500"; cout<<"\nEnter the amount to be deposited"; cin>>balance; } if(ach==2) { cout<<"\nMinimum Balance should be Rs.500"; cout<<"\nEnter the amount to be deposited"; cin>>balance; strcpy(acctyp,"Savings Account"); }} int check() { if(balance<debit) return 0; else return 1; } void transaction() { cout<<"Enter amount to be withdrawn"; cin>>debit; if(check()) balance-=debit; cout<<"Amount withdrawn\n Current balance: "<<balance; }

void display() { cout<<"\nWelcome\n"; cout<<"\n\nAccount Holder1 Name:"<<name; cout<<"\nAccount Holder2 Name:"<<aname; cout<<"\nAccount NO: "<<accno; cout<<"\nAccount type:"<<acctyp; cout<<"\n------------------------------------------------\n"; cout<<"Withdraw\tDeposit\tBalance"; cout<<"\n-------------------------------------------------"; cout<<"\n"<<credit<<"\t"<<debit<<"\t"<<balance<<"\n"; } }; class current:public accholder { char cmpname[20]; public: void getdata() { cout<<"Enter ur Company name: "; cin>>cmpname; cout<<"Minimum balance should be Rs.5000"; cout<<"Enter the amount to be deposited"; cin>>balance; strcpy(acctyp,"Current account"); }}; void main() { int choice,ac,i,uch,ech,actyp,amt,chk; clrscr(); accholder a; current *c=new current; savings *s=new savings; do{ cout<<"\n\n1.Create an account\n2.Employee Login\n3.Exit"; cout<<"\nUr choice? "; cin>>choice; cout<<"Enter your Account Type"; cout<<"\n\t1.Savings account\n\t2.Current account\n"; cin>>actyp; switch(choice) { case 1: if(actyp==1) { s->getdetails(); s->getdata(); } if(actyp==2) { c->getdetails(); c->getdata(); } break; case 2:

switch(actyp) { case 1:cout<<"Enter your Account NO:"; cin>>i; s->display(); do{ cout<<"\n\n1.Withdraw\n2.Deposit\n3.Check Balance\n4.Display\n5.Sign Out\n"; cout<<"Ur choice? "; cin>>uch; switch(uch) { case 1: s->transaction(); break; case 2: cout<< "Enter amount to be deposited"; cin>>amt; s->deposit(amt); break; case 3: s->checkbal();break; case 4: s->display();break; case 5: exit(0); } }while(uch<5); case 2: cout<<"Enter your Account NO:"; cin>>i; c->display(); do{ cout<<"\n1.Withdraw\n2.Deposit\n3.Check Balance\n4.Display\n5.Sign Out\n"; cout<<"Ur choice? "; cin>>uch; switch(uch) { case 1: c->transaction(); break; case 2: cout<< "Enter amount to be deposited"; cin>>amt; c->deposit(amt); break; case 3: c->checkbal();break; case 4: c->display();break; case 5: exit(0); } }while(uch<5); }} }while(choice<3); delete s,c; getch(); }

SAMPLE INPUT & OUTPUT: Create an account User login Exit Ur choice ? 1 Enter your account type 1.Savings account 2.Current account 1 Account No: 1 Enter Accountholder Name : Shenbaga Enter Address : Mudaliarpet Enter Contact No : 9042428767 1.Joint Account 2.Individual Ur choice ? 1 Enter additional member name: Thenmozhi 1. Both 2. Either Or survive 2 Minimum balance should be Rs.500 Enter the amount to be deposited 1000 Create an account User login Exit Ur choice ? 2 Enter your account type 1.Savings account 2.Current account 1 Welcome Accountholder1 Name: Shenbaga Accountholder2 Name: Thenmozhi Account No: 1 Account type: Savings Joint-either or survive Withdraw 0 1.Withdraw 2.Deposit 3.Check Balance 4.Display 5.Sign out Ur choice ? 2 Enter amount to be deposited 2000 Amount deposited Balance : 3000 1.Withdraw 2.Deposit 3.Check Balance 4.Display Deposit 0 Balance 1000

5.Sign out

Ur choice ? 1 Enter the amount to be withdrawn 500 Amount deposited Balance : 2500 1.Withdraw 2.Deposit 3.Check Balance 4.Display 5.Sign out Ur choice ? 4

Welcome Accountholder1 Name: Shenbaga Accountholder2 Name: Thenmozhi Account No: 1 Account type: Savings Joint-either or survive Withdraw 500 Deposit 0 Balance 2500

You might also like