Uploaded by Javeria Sarwar

include

advertisement
Program 1:
#include <iostream>
using namespace std;
class account
{
char cust_name[20];
int acc_no, balance;
char acc_type[20];
public:
void get_accinfo()
{
cout<<"\n\nEnter Customer Name :- ";
cin>>cust_name;
cout<<"Enter Account Number :- ";
cin>>acc_no;
cout<<"Enter Account Type :- ";
cin>>acc_type;
}
void display_accinfo()
{
cout<<"\n\nCustomer Name :- "<<cust_name;
cout<<"\nAccount Number :- "<<acc_no;
cout<<"\nAccount Type :- "<<acc_type;
}
};
class cur_acct
public:
account
{
staticfloat balance;
public:
void disp_currbal()
{
cout<<"\nBalance :- "<<balance;
}
void deposit_currbal()
{
float deposit;
cout<<"\nEnter amount to Deposit :- ";
cin>>deposit;
balance = balance + deposit;
}
void withdraw_currbal()
{
float penalty,withdraw;
cout<<"\n\nBalance :- "<<balance;
cout<<"\nEnter amount to be withdraw :-";
cin>>withdraw;
balance=balance-withdraw;
if(balance < 500)
{
penalty=(500-balance)/10;
balance=balance-penalty;
cout<<"\nBalance after deducting penalty : "<<balance;
}
elseif(withdraw > balance)
{
cout<<"\n\nYou have to take permission for Bank Overdraft Facility\n";
balance=balance+withdraw;
}
else
cout<<"\nAfter Withdrawl your Balance revels : "<<balance;
}
};
class sav_acct : public account
{
staticfloat savbal;
public:
void disp_savbal()
{
cout<<"\nBalance :- "<<savbal;
}
void deposit_savbal()
{
float deposit,interest;
cout<<"\nEnter amount to Deposit :- ";
cin>>deposit;
savbal = savbal + deposit;
interest=(savbal*2)/100;
savbal=savbal+interest;
}
void withdraw_savbal()
{
float withdraw;
cout<<"\nBalance :- "<<savbal;
cout<<"\nEnter amount to be withdraw :-";
cin>>withdraw;
savbal=savbal-withdraw;
if(withdraw > savbal)
{
cout<<"\n\nYou have to take permission for Bank Overdraft Facility\n";
savbal=savbal+withdraw;
}
else
cout<<"\nAfter Withdrawl your Balance revels : "<<savbal;
}
};
float cur_acct :: balance;
float sav_acct :: savbal;
void main()
{
clrscr();
cur_acct c1;
sav_acct s1;
cout<<"\nEnter S for saving customer and C for current a/c customer\n\n";
char type;
cin>>type;
int choice;
if(type=='s' || type=='S')
{
s1.get_accinfo();
while(1)
{
clrscr();
cout<<"\nChoose Your Choice\n";
cout<<"1) Deposit\n";
cout<<"2) Withdraw\n";
cout<<"3) Display Balance\n";
cout<<"4) Display with full Details\n";
cout<<"5) Exit\n";
cout<<"6) Choose Your choice:-";
cin>>choice;
switch(choice)
{
case 1 : s1.deposit_savbal();
getch();
break;
case 2 : s1.withdraw_savbal();
getch();
break;
case 3 : s1.disp_savbal();
getch();
break;
case 4 : s1.display_accinfo();
s1.disp_savbal();
getch();
break;
case 5 : goto end;
default: cout<<"\n\nEntered choice is invalid,\"TRY AGAIN\"";
}
}
}
else
{
{
c1.get_accinfo();
while(1)
{
cout<<"\nChoose Your Choice\n";
cout<<"1) Deposit\n";
cout<<"2) Withdraw\n";
cout<<"3) Display Balance\n";
cout<<"4) Display with full Details\n";
cout<<"5) Exit\n";
cout<<"6) Choose Your choice:-";
cin>>choice;
switch(choice)
{
case 1 : c1.deposit_currbal();
getch();
break;
case 2 : c1.withdraw_currbal();
getch();
break;
case 3 : c1.disp_currbal();
getch();
break;
case 4 : c1.display_accinfo();
c1.disp_currbal();
getch();
break;
case 5 : goto end;
default: cout<<"\n\nEntered choice is invalid,\"TRY AGAIN\"";
}
}
}
Program 2:
#include <iostream>
#include <iomanip>
#include <conio.h>
using namespace std;
class bank
{
char name[20];
int acno;
char actype[20];
int bal;
public :
void opbal(void);
void deposit(void);
void withdraw(void);
void display(void);
};
void bank :: opbal(void)
{
cout<<endl<<endl;
cout<<"Enter Name :-";
cin>>name;
cout<<"Enter A/c no. :-";
cin>>acno;
cout<<"Enter A/c Type :-";
cin>>actype;
cout<<"Enter Opening Balance:-";
cin>>bal;
}
void bank :: deposit(void)
{
cout<<"Enter Deposit amount :-";
int deposit=0;
cin>>deposit;
deposit=deposit+bal;
cout<<"\nDeposit Balance = "<<deposit;
bal=deposit;
}
void bank :: withdraw(void)
{
int withdraw;
cout<<"\nBalance Amount = "<<bal;
cout<<"\nEnter Withdraw Amount :-";
cin>>withdraw;
bal=bal-withdraw;
cout<<"After Withdraw Balance is "<<bal;
}
void bank :: display(void)
{
cout<<endl<<endl<<endl;
cout<<setw(50)<<"DETAILS"<<endl;
cout<<setw(50)<<"name
cout<<setw(50)<<"A/c. No.
cout<<setw(50)<<"A/c Type
cout<<setw(50)<<"Balance
}
main()
"<<name<<endl;
"<<acno<<endl;
"<<actype<<endl;
"<<bal<<endl;
{
bank o1;
int choice;
do
{
cout<<"\n\nChoice List\n\n";
cout<<"1) To assign Initial Value\n";
cout<<"2) To Deposit\n";
cout<<"3) To Withdraw\n";
cout<<"4) To Display All Details\n";
cout<<"5) EXIT\n";
cout<<"Enter your choice :-";
cin>>choice;
switch(choice)
{
case 1: o1.opbal();
break;
case 2: o1.deposit();
break;
case 3: o1.withdraw();
break;
case 4: o1.display();
break;
case 5: goto;
}
}
Program 3:
#include<iostream>
#include<conio.h>
using namespace std;
class stud
{
int rno;
char name[20];
public:
void getdata()
{
cout<<"Enter Your Roll Number ";
cin>>rno;
cout<<"Enter Your Name ";
cin>>name;
}
void putdata()
{
cout<<"Roll Number is : "<<rno<<endl;
cout<<"Name is : "<<name<<endl;
}
};
class science : public stud
{
int maths,sci;
public:
void getdata()
{
stud::getdata();
cout<<"Enter Maths Marks ";
cin>>maths;
cout<<"Enter Science Marks ";
cin>>sci;
}
void putdata()
{
stud::putdata();
cout<<"Maths Marks are : "<<maths<<endl;
cout<<"Science Marks are : "<<sci<<endl;
}
};
class commerce :public stud
{
int acc,stat;
public:
void getdata()
{
stud::getdata();
cout<<"Enter Account Marks ";
cin>>acc;
cout<<"Enter Statistics Marks ";
cin>>stat;
}
void putdata()
{
stud::putdata();
cout<<"Account Marks are : "<<acc<<endl;
cout<<"Statistics Marks are : "<<stat<<endl;
}
};
main()
{
science s1;
s1.getdata();
s1.putdata();
commerce c1;
c1.getdata();
c1.putdata();
getch();
}
Download