Sie sind auf Seite 1von 22

Program no 1:

#include<iostream>

#include<conio.h>

using namespace std;

class employee

protected:

string name;

string number;

public:

void getinfo()

cout<<"\n\nEnter Name : ";

getline(cin,name);

cout<<"\nEnter Number : ";

getline(cin,number);

};

class manager : public employee

private:
string title;

int clubdues;

public:

void manager_info()

cout<<"\n\n\tManager Info";

title="Manager";

cout<<"\n\nTitle : " << title;

employee::getinfo();

cout<<"\nClub dues = ";

cin>>clubdues;

};

class scientist : public employee

private:

string title;

string publication;

public:
void scientist_info()

cout<<"\n\n\tScientist Info";

title="Scientist";

cout<<"\n\nTitle : " << title;

cin.ignore();

employee::getinfo();

cout<<"\nEnter Publication : ";

getline(cin,publication);

};

class laborer : public employee

private:

string title;

public:

void labour_info()

cout<<"\n\n\tLaborer Info";
title = "Labour";

cout<<"\n\nTilte : " << title;

employee::getinfo();

};

int main()

manager obj1;

scientist obj2;

laborer obj3;

obj1.manager_info();

obj2.scientist_info();

obj3.labour_info();

Output:
Program no 2:
#include<iostream>

#include<conio.h>

using namespace std;

class person

private:

int age;

protected:

string name;

void person_info()

cout<<"\nEnter name : ";


getline(cin,name);

cout<<"\nEnter age : ";

cin>>age;

};

class employee

private:

int empid;

protected:

int salary;

void employee_info()

cout<<"\nEnter Employee id : ";

cin>>empid;

cout<<"\nEnter Employee Salary : ";

cin>>salary;

};

class manager : public person , public employee


{

private:

string name,type;

public:

void manager_info()

cout<<"\nenter name of manager";

getline(cin,name);

cout<<"\nType of manager : ";

getline(cin,type);

};

class itmanager : public manager

private:

int noofperson;

public:

void display()

person::person_info();

employee::employee_info();

cin.ignore();
manager::manager_info();

cout<<"\nNo Of Person : ";

cin>>noofperson;

};

int main()

itmanager obj;

obj.display();

return(0);

Output:

Program no 3:
#include<iostream>

#include<conio.h>
using namespace std;

class package

private:

string sender_name;

string sender_address;

string sender_city;

string sender_state;

string sender_zip;

string recipient_name;

string recipient_address;

string recipient_city;

string recipient_state;

string recipient_zip;

int weight;

int costperounce;

public:

package()

sender_name = "Noor";
sender_address = "hsdjklfdbvdmwflijr";

sender_city = "Lahore";

sender_state = "Punjab";

sender_zip = "52000";

recipient_name = "Mr.David";

recipient_address = "America";

recipient_city = "Los Angeles";

recipient_state = "Cbnndnlfkkk";

recipient_zip = "52320";

weight=0;

costperounce=0;

void sender_info()

cout<<"\nSender Name = " << sender_name;

cout<<"\nSender Address = " << sender_address;

cout<<"\nSender city = " << sender_city;

cout<<"\nSender state = " << sender_state;

cout<<"\nSender Zip = " << sender_zip;

}
void recipient_info()

cout<<"\n\nRecipient Name = " << recipient_name;

cout<<"\nRecipient address = " << recipient_address;

cout<<"\nRecipient city = " << recipient_city;

cout<<"\nRecipient state = " << recipient_state;

cout<<"\nRecipient Zip = " << recipient_zip;

double calculatecost()

cout<<"\n\nEnter weight = ";

cin>>weight;

cout<<"Enter cost per ounce = ";

cin>>costperounce;

return weight*costperounce;

};

class twodaypackage : public package

private:

int flatfee;
public:

twodaypackage()

flatfee =100;

void totalcost()

cout<<"\n\nFlat fee for two day package delivery = " << flatfee;

cout<<"\nTotal shipping cost of two day package delivery = " <<


calculatecost() + flatfee;

};

class overnightpackage : public package

private:

int additional_fee;

public:

void totalcost()

cout<<"\n\nStandard fee for per ounce weight is 10PKR";


cout<<"\n\nFor overnight service fee for per ounce weight is
20PKR";

cout<<"Total shipping cost for overnight service = " <<


calculatecost();

};

int main()

twodaypackage obj1;

cout<<"\n\t\t\t\tTwo Day Package Delivery";

obj1.sender_info();

obj1.recipient_info();

obj1.totalcost();

cout<<"\n";

system("PAUSE");

system("CLS");

overnightpackage obj2;

cout<<"\n\t\t\t\tOver Night Package Delivery";

obj2.sender_info();

obj2.recipient_info();

obj2.totalcost();

Output:
Program no 4:
#include<iostream>

#include<conio.h>

using namespace std;

class persontype

protected:

string firstname;

string lastname;

public:

void getinfo()

cout<<"\nEnter the first name : ";

getline(cin,firstname);
cout<<"\nEnter the last name : ";

getline(cin,lastname);

};

class doctortype : public persontype

private:

string doctor_speciality;

public:

void doctorinfo()

persontype::getinfo();

cout<<"\nEnter Doctor Speciality : ";

getline(cin,doctor_speciality);

};

class billtype : public doctortype

private:

int patient_id;
int medicine_charges;

int doctor_fee;

int room_charges;

public:

void billinfo()

doctortype::doctorinfo();

cout<<"\nEnter patient id : ";

cin>>patient_id;

cout<<"\nEnter medicine charges : ";

cin>>medicine_charges;

cout<<"\nEnter doctor fee : ";

cin>>doctor_fee;

cout<<"\nEnter room charges : ";

cin>>room_charges;

};

class patienttype : public billtype

private:
int patient_id,age;

string DOB;

string attending_physician;

string date_admit;

string date_discharge;

public:

void patientinfo()

cin.ignore();

billtype::billinfo();

cout<<"\nEnter patient id : ";

cin>>patient_id;

cout<<"\nEnter patient age : ";

cin>>age;

cout<<"\nEnter patient DOB :";

cin.ignore();

getline(cin,DOB);

cout<<"\nAttending physician name : ";

getline(cin,attending_physician);
cout<<"\nDate of admitting : ";

getline(cin,date_admit);

cout<<"\nDate of discharge : ";

getline(cin,date_discharge);

};

int main()

cout<<"\n\t\t\t\tDOCTOR INFO";

doctortype d;

d.doctorinfo();

cout<<"-------------------------------------";

cout<<"\n\t\t\t\tBILL INFO";

billtype b;

b.billinfo();

cout<<"-------------------------------------";

cout<<"\n\t\t\t\tPATIENT INFO";

patienttype p;

p.doctorinfo();

p.billinfo();
p.patientinfo();

getch();

return(0);

Output:

Program no 5:
#include<iostream>

#include<conio.h>

using namespace std;


class investment

protected:

int initial_value;

int current_value;

int profit;

float percent_profit;

public:

investment()

initial_value=4000;

current_value=12000;

void investment_display()

profit = current_value - initial_value;

cout<<"\nProfit = " << profit;

percent_profit = profit/initial_value;

cout<<"\nPercentage of profit is = " << percent_profit <<" % ";

};
class house

protected:

string street_address;

string square_feet;

public:

house()

street_address = "222Block, DHA Phase 6, Lahore";

square_feet = "2500";

void house_display()

cout<<"\nStreet Address = "<< street_address;

cout<<"\nSquare Feet = "<< square_feet;

};

class houseinvestment : public investment , public house

public:

void houseinfo()

{
investment_display();

house_display();

};

int main()

houseinvestment obj;

cout<<"\n\t\t\tDetails Of House";

obj.houseinfo();

Output:

Das könnte Ihnen auch gefallen