You are on page 1of 25

Problem_01

#include<iostream>
#include<string>
#include<sstream>
using namespace std;
class Person
{
public:
Person() { for (int i = 0; i < 50; i++) { PhoneNum[i] = 0;} };
void display() {
cout << "\t\t\t\tI am in person" << endl;
}
void setVAL(int i)
{
this->Name[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tName : "; cin >> this->Name[i];
stringstream ss(this->Name[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl; strcheck = true; }
else { strcheck = false; }
}
this->Adress[i] = "NULL";
strcheck = true;
strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tAdress : "; cin >> this->Adress[i];
stringstream ss(this->Adress[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl; strcheck = true; }
else { strcheck = false; }
}
this->Email[i] = "NULL";
strcheck = true;
strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tEmail : "; cin >> this->Email[i];
stringstream ss(this->Email[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl; strcheck = true; }
else { strcheck = false; }
}
cout << "\t\t\t\tTell : ";
while (!(cin >> PhoneNum[i]))
{
cout << "\t\t\t\tInputError" << endl;
cout << "\t\t\t\tTell : ";
cin.clear();
cin.ignore(50, '\n');
}
}
string getName(int i) { return this->Name[i]; };
string getAdress(int i) { return this->Adress[i]; };
string getEmail(int i) { return this->Email[i]; };
int getPhoneNum(int i) { return this->PhoneNum[i]; };
void checkO(int i)
{
cout << "\t\t\t\tName : " << this->getName(i) << endl;
cout << "\t\t\t\tAdress : " << this->getAdress(i) << endl;
cout << "\t\t\t\tEmail : " << this->getEmail(i) << endl;
cout << "\t\t\t\tPhone Number : " << this->getPhoneNum(i) << endl;
}
~Person() {};
private: string *Name=new string[50], *Adress=new string[50], *Email=new string[50]; int PhoneNum[50];
};
class Student:protected Person
{
public:
Student() { for (int i = 0; i < 50; i++) { CGPA[i] = 0; RollNum[i] = 0; } };
void display() {
cout << "\t\t\t\tEnter Number of Students you want to Enter Data : "; cin >> size;
cout << "\t\t\t\tI am in Student" << endl;
for (int i = 0; i < size; i++)
{
cout << "\n\t\t\t\tInput Data For Student " << i + 1 << endl;
StudentData.setVAL(i);
cout << "\t\t\t\tRoll Num : "; cin >> StudentData.RollNum[i];
cout << "\t\t\t\tCGPA : "; cin >> StudentData.CGPA[i];
}
for (int i = 0; i < size; i++)
{
cout << "\n\t\t\t\tOutput Data For Student " << i + 1 << endl;
StudentData.checkO(i);
cout << "\t\t\t\tRoll Num : " << StudentData.RollNum[i] << endl;
cout << "\t\t\t\tCGPA : " << StudentData.CGPA[i] << endl;
}
}
~Student() {};
private: int RollNum[50]; float CGPA[50]; int size = 0;
}StudentData;
class Employee :protected Person
{
public:
Employee() { for (int i = 0; i < 50; i++) { salary[i] = 0; } };
void display() {
cout << "\t\t\t\tI am in Employee" << endl;
cout << "\t\t\t\tEnter Number of Employees you want to Enter Data : "; cin >> size;
for (int i = 0; i < size; i++)
{
//cout << "\t\t\t\tInput Data For Employee " << i + 1 << endl;
obj.setVAL(i);
obj.office[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tOffice : "; cin >> obj.office[i];
stringstream ss(obj.office[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl; strcheck =
true; }
else { strcheck = false; }
}
obj.setVAL(i);
obj.DateHired[i] = "NULL";
strcheck = true;
strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tDateHired : "; cin >> obj.DateHired[i];
stringstream ss(obj.DateHired[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl; strcheck =
true; }
else { strcheck = false; }
}
cout << "\t\t\t\tSalary : ";
while (!(cin >> obj.salary[i]))
{
cout << "\t\t\t\tInputError" << endl;
cout << "\t\t\t\tSalary : ";
cin.clear();
cin.ignore(50, '\n');
}
}
for (int i = 0; i < size; i++)
{
//cout << "\t\t\t\tInput Data For Employee " << i + 1 << endl;
obj.checkO(i);
cout << "\t\t\t\tOffice : " << obj.office[i] << endl;
cout << "\t\t\t\tDate Hired : " << obj.DateHired[i] << endl;
cout << "\t\t\t\tSalery : " << obj.salary[i] << endl;
}
}
~Employee() {};
private: string office[50], DateHired[50]; int salary[50]; int size = 0;
}obj;
class Faculty:protected Employee
{
public:
Faculty() { };
void display() {
cout << "\t\t\t\tI am in faculty" << endl;
cout << "\t\t\t\tEnter Number of Faculty you want to Enter Data : "; cin >> size;
for (int i = 0; i < size; i++)
{
cout << "\n\t\t\t\tInput Data For Faculty " << i + 1 << endl;
FacultyData.setVAL(i);
FacultyData.OfficeHours[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tOfficeHours : "; cin >> FacultyData.OfficeHours[i];
stringstream ss(FacultyData.OfficeHours[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl; strcheck =
true; }
else { strcheck = false; }
}
FacultyData.Rank[i] = "NULL";
strcheck = true;
strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tRank : "; cin >> FacultyData.Rank[i];
stringstream ss(FacultyData.Rank[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl; strcheck =
true; }
else { strcheck = false; }
}
}
for (int i = 0; i < size; i++)
{
cout << "\n\t\t\t\tOutput Data For Faculty " << i + 1 << endl;
FacultyData.checkO(i);
cout << "\t\t\t\tOfficeHours : " << FacultyData.OfficeHours[i] << endl;
cout << "\t\t\t\tRank : " << FacultyData.Rank[i] << endl;
}
}
~Faculty() {};
private: string OfficeHours[50]; string Rank[50]; int size = 0;
}FacultyData;
class Staff:protected Employee
{
public:
Staff() { };
void display() {
cout << "\t\t\t\tI am in Staff" << endl;
cout << "\t\t\t\tEnter Number of Staff you want to Enter Data : "; cin >> size;
for (int i = 0; i < size; i++)
{
cout << "\n\t\t\t\tInput Data For Staff " << i + 1 << endl;
StaffData.setVAL(i);
StaffData.title[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tTitle : "; cin >> StaffData.title[i];
stringstream ss(StaffData.title[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl; strcheck =
true; }
else { strcheck = false; }
}
cout << "\t\t\t\tTitle : "; cin >> StaffData.title[i];
}
for (int i = 0; i < size; i++)
{
cout << "\n\t\t\t\tOutput Data For Staff " << i + 1 << endl;
StaffData.checkO(i);
cout << "\t\t\t\tTitle : " << StaffData.title[i] << endl;
}
}
~Staff() {};
private: string title[50]; int size = 0;
}StaffData;
void call()
{
Student obj; Faculty obj2; Staff obj3;
int check = 0;
cout << "\t\t\t\tSelect The Type You want to Enter Data : \n\t\t\t\t1-Student\n\t\t\t\t2-
Faculty\n\t\t\t\t3-Staff : "; cin >> check;
switch (check) {
case 1: obj.display(); break;
case 2: obj2.display(); break;
case 3: obj3.display(); break;
default: break; }
}
int main()
{
call();
return 0;
}
Problem_02:
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
class staff
{
public:
staff() { };
void setVAL(int i)
{
this->Name[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tName : "; cin >> this->Name[i];
stringstream ss(this->Name[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
this->Code[i] = "NULL";
strcheck = true;
strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tCode : "; cin >> this->Code[i];
stringstream ss(this->Code[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
}
string getName(int i) { return this->Name[i]; };
string getCode(int i) { return this->Code[i]; };
void checkO(int i)
{
cout << "\t\t\t\tName : " << this->getName(i) << endl;
cout << "\t\t\t\tCode : " << this->getCode(i) << endl;
}
~staff() {};

private: string *Name=new string[50], *Code=new string[50];


};
class Teacher :protected staff
{
public:
Teacher() { };
void display() {
cout << "\t\t\t\tEnter Number of Teachers you want to Enter Data : "; cin
>> size;
for (int i = 0; i < size; i++)
{
TeacherData.setVAL(i);
TeacherData.subject[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tSubject : "; cin >> TeacherData.subject[i];
stringstream ss(TeacherData.subject[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
TeacherData.setVAL(i);
TeacherData.publication[i] = "NULL";
strcheck = true;
strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tPublication : "; cin >>
TeacherData.publication[i];
stringstream ss(TeacherData.publication[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
}
for (int i = 0; i < size; i++)
{
TeacherData.checkO(i);
cout << "\t\t\t\tSubject : " << TeacherData.subject[i] << endl;
cout << "\t\t\t\tPublications : " << TeacherData.publication[i] <<
endl;
}
}
~Teacher() {};
private: string subject[50], publication[50]; int size = 0;
}TeacherData;
class Officer :protected staff
{
public:
Officer() { };
void display() {
cout << "\t\t\t\tEnter Number of Officer you want to Enter Data : "; cin >>
size;
for (int i = 0; i < size; i++)
{
OfficerData.setVAL(i);
OfficerData.grade[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tGrade : "; cin >> OfficerData.grade[i];
stringstream ss(OfficerData.grade[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
}
for (int i = 0; i < size; i++)
{
OfficerData.checkO(i);
cout << "\t\t\t\tGrade : " << OfficerData.grade[i] << endl;
}
}
~Officer() {};
private: string grade[50]; int size = 0;
}OfficerData;
class Typist :protected staff
{
public:
Typist() { for (int i = 0; i < 50; i++) { speed[i] = 0; } };
void display() {
for (int i = 0; i < size; i++)
{
cout << "\t\t\t\tSpeed : ";
while (!(cin >> TypistData.speed[i]))
{
cout << "\t\t\t\tInputError" << endl;
cout << "\t\t\t\tSalary : ";
cin.clear();
cin.ignore(50, '\n');
}
}
for (int i = 0; i < size; i++)
{
TypistData.checkO(i);
cout << "\t\t\t\tSpeed : " << TypistData.speed[i] << endl;
}
}
~Typist() {};
private: int speed[50]; int size = 0;
}TypistData;
class regular :protected Typist {
public:
regular() { };
void display()
{
cout << "\t\t\t\tEnter Number of RegualrTypist you want to Enter Data : ";
cin >> size;
for (int i = 0; i < size; i++) {
cout << "\n\t\t\t\tInput Data For RegularTypist " << i + 1 << endl;
RegularTypist.setVAL(i);
}
};
~regular() {};
protected:int size = 0;
}RegularTypist;
class casual:protected Typist
{
public:
casual() { };
void display() {
cout << "\t\t\t\tEnter Number of CasualTypist you want to Enter Data : ";
cin >> size;
for (int i = 0; i < size; i++)
{
cout << "\n\t\t\t\tInput Data For CasualTypist " << i + 1 << endl;
CasualTypist.setVAL(i);
CasualTypist.DailyWages[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tDailyWages : "; cin >>
CasualTypist.DailyWages[i];
stringstream ss(CasualTypist.DailyWages[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
cout << "\t\t\t\tDailyWages : "; cin >> CasualTypist.DailyWages[i];
}
for (int i = 0; i < size; i++)
{
cout << "\n\t\t\t\tOutput Data For CasualTypist " << i + 1 << endl;
CasualTypist.checkO(i);
cout << "\t\t\t\tDailyWages : " << CasualTypist.DailyWages[i] <<
endl;
}
}
~casual() {};
private: string DailyWages[50]; int size = 0;
}CasualTypist;
void call()
{
Teacher obj; Officer obj2; regular obj3; casual obj4;
int check = 0;
cout << "\t\t\t\tSelect The Type You want to Enter Data : \n\t\t\t\t1-
Teacher\n\t\t\t\t2-Officer\n\t\t\t\t3-RegularTypist : \n\t\t\t\t4-CasualTypist : "; cin
>> check;
switch (check) {
case 1: obj.display() ; break;
case 2: obj2.display(); break;
case 3: obj3.display(); break;
case 4 :obj4.display(); break;
default: break; }
}
int main()
{
call();
return 0;
}
Problem_03:
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
class staff
{
public:
staff() { };
void setVAL(int i)
{
this->Name[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tName : "; cin >> this->Name[i];
stringstream ss(this->Name[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
this->Code[i] = "NULL";
strcheck = true;
strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tCode : "; cin >> this->Code[i];
stringstream ss(this->Code[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
}
string getName(int i) { return this->Name[i]; };
string getCode(int i) { return this->Code[i]; };
void checkO(int i)
{
cout << "\t\t\t\tName : " << this->getName(i) << endl;
cout << "\t\t\t\tCode : " << this->getCode(i) << endl;
}
~staff() {};

private: string *Name=new string[50], *Code=new string[50];


};
class Teacher :protected staff
{
public:
Teacher() { };
void display() {
cout << "\t\t\t\tEnter Number of Teachers you want to Enter Data : "; cin
>> size;
for (int i = 0; i < size; i++)
{
TeacherData.setVAL(i);
TeacherData.subject[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tSubject : "; cin >> TeacherData.subject[i];
stringstream ss(TeacherData.subject[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
TeacherData.setVAL(i);
TeacherData.publication[i] = "NULL";
strcheck = true;
strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tPublication : "; cin >>
TeacherData.publication[i];
stringstream ss(TeacherData.publication[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
}
for (int i = 0; i < size; i++)
{
TeacherData.checkO(i);
cout << "\t\t\t\tSubject : " << TeacherData.subject[i] << endl;
cout << "\t\t\t\tPublications : " << TeacherData.publication[i] <<
endl;
}
}
~Teacher() {};
private: string subject[50], publication[50]; int size = 0;
}TeacherData;
class Officer :protected staff
{
public:
Officer() { };
void display() {
cout << "\t\t\t\tEnter Number of Officer you want to Enter Data : "; cin >>
size;
for (int i = 0; i < size; i++)
{
OfficerData.setVAL(i);
OfficerData.grade[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tGrade : "; cin >> OfficerData.grade[i];
stringstream ss(OfficerData.grade[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
}
for (int i = 0; i < size; i++)
{
OfficerData.checkO(i);
cout << "\t\t\t\tGrade : " << OfficerData.grade[i] << endl;
}
}
~Officer() {};
private: string grade[50]; int size = 0;
}OfficerData;
class Typist :protected staff
{
public:
Typist() { for (int i = 0; i < 50; i++) { speed[i] = 0; } };
void display() {
for (int i = 0; i < size; i++)
{
cout << "\t\t\t\tSpeed : ";
while (!(cin >> TypistData.speed[i]))
{
cout << "\t\t\t\tInputError" << endl;
cout << "\t\t\t\tSalary : ";
cin.clear();
cin.ignore(50, '\n');
}
}
for (int i = 0; i < size; i++)
{
TypistData.checkO(i);
cout << "\t\t\t\tSpeed : " << TypistData.speed[i] << endl;
}
}
~Typist() {};
private: int speed[50]; int size = 0;
}TypistData;
class regular :protected Typist {
public:
regular() { };
void display()
{
cout << "\t\t\t\tEnter Number of RegualrTypist you want to Enter Data : ";
cin >> size;
for (int i = 0; i < size; i++) {
cout << "\n\t\t\t\tInput Data For RegularTypist " << i + 1 << endl;
RegularTypist.setVAL(i);
}
};
~regular() {};
protected:int size = 0;
}RegularTypist;
class casual:protected Typist
{
public:
casual() { };
void display() {
cout << "\t\t\t\tEnter Number of CasualTypist you want to Enter Data : ";
cin >> size;
for (int i = 0; i < size; i++)
{
cout << "\n\t\t\t\tInput Data For CasualTypist " << i + 1 << endl;
CasualTypist.setVAL(i);
CasualTypist.DailyWages[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tDailyWages : "; cin >>
CasualTypist.DailyWages[i];
stringstream ss(CasualTypist.DailyWages[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
cout << "\t\t\t\tDailyWages : "; cin >> CasualTypist.DailyWages[i];
}
for (int i = 0; i < size; i++)
{
cout << "\n\t\t\t\tOutput Data For CasualTypist " << i + 1 << endl;
CasualTypist.checkO(i);
cout << "\t\t\t\tDailyWages : " << CasualTypist.DailyWages[i] <<
endl;
}
}
~casual() {};
private: string DailyWages[50]; int size = 0;
}CasualTypist;
class Education : private Teacher
{
public:
Education() {};
void set(int i)
{
EducationOBJ.setVAL(i);
}
~Education() {};

private:
}EducationOBJ;
class HighestQual:private Education
{
public:
HighestQual() {};
void display() {
cout << "\t\t\t\tEnter Number of HighestQualityTeachers you want to Enter
Data : "; cin >> size;
for (int i = 0; i < size; i++)
{
HighestQualOBJ.set(i);
HighestQualOBJ.Degree[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tDegree : "; cin >> HighestQualOBJ.Degree[i];
stringstream ss(HighestQualOBJ.Degree[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
//HighestQualOBJ.set(i);
HighestQualOBJ.sports[i] = "NULL";
strcheck = true;
strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tSports : "; cin >> HighestQualOBJ.sports[i];
stringstream ss(HighestQualOBJ.sports[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
}
}
~HighestQual() {};

private: string Degree[50], sports[50]; int size = 0;


}HighestQualOBJ;
class HighestGeneralQual :private Education
{
public:
HighestGeneralQual() {};
void display() {
cout << "\t\t\t\tEnter Number of HighestQualityTeachers you want to Enter
Data : "; cin >> size;
for (int i = 0; i < size; i++)
{
HighestGeneralQualOBJ.set(i);
HighestGeneralQualOBJ.Medals[i] = "NULL";
bool strcheck = true;
int strcheck1 = 0;
while (strcheck == true)
{
cout << "\t\t\t\tDegree : "; cin >>
HighestGeneralQualOBJ.Medals[i];
stringstream ss(HighestGeneralQualOBJ.Medals[i]);
if (ss >> strcheck1) { cout << "\t\t\t\tInputError" << endl;
strcheck = true; }
else { strcheck = false; }
}
}
}
~HighestGeneralQual() {};

private: string Medals[50]; int size = 0;

}HighestGeneralQualOBJ;
void call()
{
Teacher obj; Officer obj2; regular obj3; casual obj4;
int check = 0;
cout << "\t\t\t\tSelect The Type You want to Enter Data : \n\t\t\t\t1-
Teacher\n\t\t\t\t2-Officer\n\t\t\t\t3-RegularTypist : \n\t\t\t\t4-CasualTypist : "; cin
>> check;
switch (check) {
case 1: obj.display() ; break;
case 2: obj2.display(); break;
case 3: obj3.display(); break;
case 4 :obj4.display(); break;
default: break; }
}
int main()
{
call();
return 0;
Problem_04
#include<iostream>
#include<sstream>
#include<string>
#include<Windows.h>
using namespace std;
class ElectricCar
{
public:
ElectricCar() { Battery_Level = 30; };
void Recharge(char mode)
{
system("cls");
cout << "Battery Mode Charge : " << endl;
if (Battery_Level <= 100)
{
if (mode=='b')
{
Battery_Level--;
}
else
{
Battery_Level++;
}
}
else
{
cout << "Full Battery !.." << endl;
}
Show_Bat();
}
void Show_Bat()
{
cout << "Battery Level : \n" << Battery_Level << "%" << endl;
for (int i = 0; i < Battery_Level; i++)
{
cout << "|";
Sleep(100);
}
}
~ElectricCar(){};

private: int Battery_Level = 0;


};
class PetrolCar
{
public:
PetrolCar() { Fuel_Level = 80; };
void Fill_Up(char mode)
{
system("cls");
cout << "Petrol Mode fuel : " << endl;
if (Fuel_Level <= 50)
{
if (mode == 'f')
{
Fuel_Level = Fuel_Level - 0.5;
}
else
{
Fuel_Level = Fuel_Level + 0.5;
}
}
else
{
cout << "Fuel Tank Full !.. " << endl;
}
Show_Fuel();
}
void Show_Fuel()
{
cout << "Fuel Level : " << Fuel_Level << "%" << endl;
for (int i = 0; i < Fuel_Level; i++)
{
cout << "|";
Sleep(100);
}
}
~PetrolCar(){};

private:double Fuel_Level;
};
class HybridCar :private ElectricCar, private PetrolCar
{
public:
HybridCar() { Running_Mode = 'N'; };
void LetGo()
{
cout << "Select Mode To Drive Vehicle : \n1-Enter 'b' for Battery Mode.\n2-
Enter 'f' for Fuel Mode."; cin >> call.Running_Mode;
Switch_Mode(call.Running_Mode);
}
void Switch_Mode(char mode)
{
if (mode == 'b')
{
call.Running_Mode = mode;
Run(call.Running_Mode);
}
else if (mode == 'f')
{
call.Running_Mode = mode;
Run(call.Running_Mode);
}
}
void Run(char mode)
{
if (mode == 'b')
{
call.Recharge(mode);
}
else if (mode == 'f')
{
call.Fill_Up(mode);
}
}
~HybridCar() {};

private:char Running_Mode;
}call;
void Drive()
{
HybridCar obj;
obj.LetGo();
}
int main()
{
Drive();
return 0;
}
Problem_06
#include<iostream>
#include<string>
using namespace std;
class Musicians
{
public:
Musicians() { String(); Wind(); Perc(); };
void String() {
StringV[0] = "veena"; StringV[1] = "guitar";
StringV[2] = "sitar"; StringV[3] = "sarod";
StringV[4] = "mandolin";
}
void Wind() {
WindV[0] = "flute"; WindV[1] = "clarinet sexaphone";
WindV[2] = "nadhaswaram"; WindV[3] = "piccolo";
}
void Perc() {
PercV[0] = "tabla"; PercV[1] = "mridangam";
PercV[2] = "bangos"; PercV[3] = "drums";
PercV[4] = "tambour";
}
void getString()
{
for (int i = 0; i < 5; i++)
{
cout << "StringEquipment " << i + 1 << " : " << StringV[i] << endl;
}
}
void getWind()
{
for (int i = 0; i < 4; i++)
{
cout << "WindEquipment " << i + 1 << " : " << WindV[i] << endl;
}
}
void getPerc()
{
for (int i = 0; i < 5; i++)
{
cout << "PercEquipment " << i + 1 << " : " << PercV[i] << endl;
}
}
~Musicians() {};
private:string StringV[5], WindV[4], PercV[5];
};
class TypeINS:protected Musicians
{
public:
TypeINS() { check = 'n'; };
void show()
{
cout << "Which type of instruments you want to show \na-String
Instruments\nb-Wind Instruments\nc-Percussion Instruments" << endl;
cin >> check;
switch (check) {
case 'a': getString(); break;
case 'b': getWind(); break;
case 'c': getPerc(); break;
default: break; }
}
~TypeINS() {};
private:char check;
};
int main()
{
TypeINS obj;
obj.show();
return 0;
}
Problem_07
#include<iostream>
#include<string>
using namespace std;
class PersonData
{
public:
PersonData() {};
void InputCustomerData()
{
cout << "FirstName : "; cin >> firstname;
cout << "lastName : "; cin >> lastname;
cout << "Adress : "; cin >> adress;
cout << "City : "; cin >> state;
}
void DisplayCustomerData()
{
cout << "FirstName : " << firstname << endl;
cout << "lastName : " << lastname << endl;
cout << "Adress : " << adress << endl;
cout << "City : " << state << endl;
}
~PersonData() {};
private: string firstname, lastname, adress, city, state;
};
class CustomerData:public PersonData
{
public:
CustomerData() { customernum = 0; mailinglist = true; boolcheck = 0; };
void InputCustomerData()
{
cout << "CustomerNumber : "; cin >> customernum;
cout << "You want to be in the mailing List if yes press 1 if no press 0 :
"; cin >> boolcheck;
if (boolcheck == 1) { mailinglist = true; }
else { mailinglist = false; }
}
void DisplayCustomerData()
{
cout << "CustomerNumber : " << customernum << endl;
cout << "Mailing List : ";
if (mailinglist == true) { cout << "Yes" << endl; }
else { cout << "No" << endl; }
}
~CustomerData() {};

private:int customernum; bool mailinglist; int boolcheck;


};
void call()
{
CustomerData obj, obj2;
obj2.PersonData::InputCustomerData();
obj.CustomerData::InputCustomerData();
obj2.PersonData::DisplayCustomerData();
obj.CustomerData::DisplayCustomerData();
}
int main()
{
call();
return 0;
}
Problem_08
#include<iostream>
#include<string>
using namespace std;
class bank
{
public:
bank() { AccNumber = 0; check = 0; bankbalance = 0; };
void setAccInfo()
{
cout << "Name : "; cin >> CustomerName;
cout << "Account Number : "; cin >> AccNumber;
cout << "Account Title S for Saving and C for Current : "; cin >> AccTitle;
cout << "Bank Balance deposit : "; cin >> bankbalance;
}
void getAccInfo()
{
cout << "Name : " << CustomerName << endl;
cout << "Account Number : " << AccNumber << endl;
cout << "Account Title : " << AccTitle << endl;
cout << "Bank Balance deposited : " << bankbalance;
}
~bank() {};

protected:string CustomerName; int AccNumber, check, bankbalance; char AccTitle;


};
class cur_acct:protected bank
{
public:
cur_acct() { checkbook = 0; cashout = 0; };
void setAccInfo()
{
bank::setAccInfo();
cur_acct::getAccInfo();
}
void getAccInfo()
{
bank::getAccInfo();
cout << "You have checkBook Facilty. Enter Money You want to cash Out : ";
cin >> cashout;
cout << "Bank Balance deposited : " << bankbalance << endl;
bankbalance = bankbalance - cashout;
cout << "Current Bank Balance after cashOUT : " << bankbalance << endl;
if (bankbalance < 500)
{
cout << "Penalty Imposed On account Holder : ";
}
bankbalance = bankbalance - 5000;
}
~cur_acct(){};

private:int checkbook, cashout;


};
class sav_acct :protected bank
{
public:
sav_acct(){};
void setAccInfo()
{
bank::setAccInfo();
sav_acct::getAccInfo();
}
void getAccInfo()
{
bank::getAccInfo();
cout << "Bank Balance deposited : " << bankbalance << endl;
bankbalance = bankbalance + ((bankbalance / interest) * 100);
cout << "Current Bank Balance With Interest : " << bankbalance << endl;
}
~sav_acct() {};
private:int interest = 20;
};
void call()
{
int check = 0;
cur_acct obj; sav_acct obj1;
cout << "Which Type of account You want to open : \n1-Saving Account\n2-Current
Account";
cin >> check;
switch (check) {
case 1: obj1.sav_acct::setAccInfo(); break;
case 2: obj.cur_acct::setAccInfo(); break;
default: break;
}
}
int main()
{
call();
return 0;
}
Problem_09
#include<iostream>
#include<string>
using namespace std;
class Books
{
public:
Books() {
authors = new string[10]; title = new string[10];
publisher = new string[10]; price = new int[10];
stock = new int[10 * 10];
authors[0] = "Mark Twain"; authors[1] = "Kazi Nasrul Islam";
authors[2] = "George Orwell"; authors[3] = "Lewis Wallace";
authors[4] = "Babur"; authors[5] = "Kautilya";
authors[6] = "AdolfHitler"; authors[7] = "Oliver GoldSmith";
authors[8] = "Edward Gibbon"; authors[9] = "H.G.Wells";
title[0] = "Adventures OF Tom Sawyer by Mark Twain";
title[1] = "Agni Veena by Kazi Nasrul Islam";
title[2] = "Animal Farm by George Orwell";
title[3] = "Ben Hur Lewis Wallace";
title[4] = "BaburNama by Babur";
title[5] = "Arthashastra by Kautilya";
title[6] = "Mein Kampf by AdolfHitler";
title[7] = "The Wikar of WakeField by Oliver GoldSmith";
title[8] = "The decline and Fall of Roman Empire by Edward Gibbon";
title[9] = "Time Machine by H.G.Wells";
for (int i = 0; i < 10; i++)
{
publisher[i] = "MasterPrinters";
stock[i] = 10;
}
price[0] = 1000; price[1] = 2000; price[3] = 500; price[4] = 1000;
price[5] = 2000; price[6] = 1000; price[7] = 3000; price[8] = 500; price[9]
= 5000;
};
void BookSET(int i) {
authors = new string[i]; title = new string[i];
publisher = new string[i]; price = new int[i];
stock = new int[i*10];
};
void DisplayBooksInfo()
{
for (int i = 0; i < 10; i++)
{
cout << "Book Stock No " << i + 1 << " Name : " << title[i] << endl;
cout << "Book Author No " << i + 1 << " AuthorName : " << authors[i]
<< endl;
cout << "No of Books With Name " << title[i] << " available are : "
<< stock[i] << endl;
}
}
~Books() {};

private:string* authors, * title, * publisher; int* price, * stock;


};
class BookInfo:private Books
{
public:
BookInfo() {};
void call()
{
DisplayBooksInfo();
cout << "Enter Which Book you want to Buy : Enter Book Number : "; cin >>
check;
BookSET(check);
DisplayBooksInfo();
}
~BookInfo() {};

private:int check;
};
int main()
{
BookInfo obj;
obj.call();
return 0;
}

You might also like