You are on page 1of 7

TASK 1

#include<iostream>
#include<string>
using namespace std;
class Emp
{
string name;
int empID;
public:
Emp();
Emp(string l, int g)
{
name = l;
empID = g;
}
};
Emp::Emp()
{
name = " ";
empID = 0;
}
class Hourly :public Emp
{
int wage;
public:
Hourly() :Emp()
{
wage = 0;
}
Hourly(int w, string n, int id) :Emp(n, id) {
wage = w;
}
int hourly_income(int);
};
int Hourly::hourly_income(int hours)
{
return hours * wage;
}
class Permanent :public Emp
{
int wage;
public:
Permanent() :Emp()
{
cout << "YOU ARE A PERMANENT EMPLOYEE:\t" << endl;
wage = 0;
}
Permanent(int w, string name, int empid) :Emp(name, empid) {
cout << "YOU ARE A PERMANENT EMPLOYEE:\t" << endl;
wage = w;
}
int income();
};
int Permanent::income()
{
return 240 * wage;
}
int main()
{
string name;
int id;
int wage1;
cout << "ENTER YOU NUMBER OF WORKING HOURS:\t";
int h;
cin >> h;
cout << "Enter Your Name:\t";
cin >> name;
cout << "Enter Your ID:\t";
cin >> id;
if (h >= 240)
{
Permanent p1(150, name, id);
wage1 = p1.income();
cout << "YOUR MONTHLY WAGE AS A PERMANENT EMPLOYEE:\t" << wage1 <<
endl;
}
else
{
Hourly h1(150, name, id);
wage1 = h1.hourly_income(h);
cout << "YOUR MONTHLY WAGE AS A HOURLY EMPLOYEE:\t" << wage1 << endl;
}
return 0;
}
TASK 2
#include<iostream>
#include<string>
using namespace std;
class Bankaccount
{
private:
int ID;
int balance;
public:
Bankaccount(int account = 0, int bal = 0)
{
ID = account;
balance = bal;
}
void balanceInquiry()
{
cout << "THE AMOUNT OF MONEY IN ACCOUNT IS:" << endl;
cout << balance << endl;
}
int GETbal() {
return balance;
}
void SETbal(int& b)
{
balance = b;
}
};
class CurrentAccount :protected Bankaccount
{
public:
CurrentAccount(int acc1 = 0, int bl1 = 0) :Bankaccount(acc1, bl1) {}
void AmountWidthdrawn()
{
int withdraw;
int bal1 = 0;
cout << "ENTER THE AMOUNT YOU WANT TO WIDHDRAW:\t";
cin >> withdraw;
bal1 = Bankaccount::GETbal();
if ( bal1 - withdraw >= 5000)
{
bal1 = bal1 - withdraw;
}
else
{
cout << "YOU CANNOT WITHDRAW THIS AMOUNT OF MONEY FROM A
CURRENT ACCOUNT" << endl;
}
cout << "YOUR BALANCE IS:\t" << bal1 << endl;
Bankaccount::SETbal(bal1);
}
void AmountDeposit()
{
int b2 = Bankaccount::GETbal();
int deposit;
cout << "ENTER THE MONEY YOU WANT TO DEPOSIT:\t";
cin >> deposit;
b2 = b2 + deposit;
cout << "THE BALANCE IS:\t" << b2 << endl;
Bankaccount::SETbal(b2);
}
};
class Savingaccount :protected Bankaccount
{
public:
Savingaccount(int acc2 = 0, int bl2 = 0) :Bankaccount(acc2, bl2) {}
void AmountWidthdrawn()
{
int withdraw;
int b3 = 0;
cout << "ENTER THE AMOUNT YOU WANT TO WIDHDRAW:\t";
cin >> withdraw;
b3 = Bankaccount::GETbal();
if (b3 - withdraw >= 10000)
{
b3 = b3 - withdraw;
}
else
{
cout << "YOU CANNOT WITHDRAW THIS AMOUNT OF MONEY FROM A
SAVINGS ACCOUNT" << endl;
}
cout << "YOUR BALANCE IS:\t" << b3 << endl;
Bankaccount::SETbal(b3);
}
void AmountDeposit()
{
int b5 = Bankaccount::GETbal();
int deposit;
cout << "ENTER THE MONEY YOU WANT TO DEPOSIT:\t";
cin >> deposit;
b5 = b5 + deposit;
cout << "THE BALANCE IS:\t" << b5 << endl;
Bankaccount::SETbal(b5);
}
};
int main()
{
int choice;
cout << "IF YOU WANT A CURRENT ACCOUNT PRESS 1." << endl;
cout << "IF YOU WANT A SAVING ACCOUNT PRESS 2." << endl;
cin >> choice;
if (choice == 1)
{
int id;
cout << "ENTER YOU ID:\t";
cin >> id;
int balance;
cout << "ENTER ACCOUNT BALANCE:\t";
cin >> balance;
Bankaccount b1(id, balance);
b1.balanceInquiry();
CurrentAccount c1(id, balance);
c1.AmountWidthdrawn();
c1.AmountDeposit();
}
else
{
int id;
cout << "ENTER YOU ID:\t";
cin >> id;
int balance;
cout << "ENTER ACCOUNT BALANCE:\t";
cin >> balance;
Bankaccount b2(id, balance);
b2.balanceInquiry();
Savingaccount s1(id, balance);
s1.AmountWidthdrawn();
s1.AmountDeposit();
}
system("pause");
return 0;
}

TASK 3
#include<iostream>
#include<string>
using namespace std;
class person
{
string name;
int bday;
public:
person()
{
name = nullptr;
bday = 0;
}
person(string name1, int yob)
{
name = name1;
bday = yob;
}
void print()
{
cout << "NAME:\t" << name << endl;
cout << "YEAR OF BIRTH:\t" << bday << endl;
}
};
class student :public person
{
int studentID;
int semester;
public:
student() :person()
{
studentID = 0;
semester = 0;
}
student(int sId, int sem, string n1, int y) :person(n1, y)
{
studentID = sId;
semester = sem;
}
};
class employee :public person
{
int employeeID;
int joiningYear;
string jobTitle;
int courseID;
string courseTitle;
public:
employee() :person()
{
employeeID = 0;
joiningYear = 0;
jobTitle = nullptr;
courseID = 0;
courseTitle = nullptr;
}
employee(int em, int jy, string title, int cId, string cT, string n, int
yb) :person(n, yb)
{
employeeID = em;
joiningYear = jy;
jobTitle = title;
courseID = cId;
courseTitle = cT;
}
void set_title(string t);
string get_title();
void print();
void setCourseid(int cId);
void setCoursetitle(string g);
};
void employee::set_title(string t)
{
jobTitle = t;
}
string employee::get_title()
{
return jobTitle;
}
void employee::print()
{
cout << "The joining year is " << joiningYear << endl;
cout << "The Employee id is " << employeeID << endl;
cout << "The jobtitle is " << jobTitle << endl;
cout << "The course id is " << courseID << endl;
cout << "The Coursetitle is " << courseTitle << endl;
}
void employee::setCourseid(int cId)
{
courseID = cId;
}
void employee::setCoursetitle(string g)
{
courseTitle = g;
}
class administration :public employee
{
public:
administration(int em, int jy, string title, string name, int bday, int cId =
0, string cT = "") :employee(em, jy, title, cId, cT, name, bday)
{}
void set_Title(string h);
string get_title();
void print();
};
void administration::set_Title(string h)
{
employee::set_title(h);
}
string administration::get_title()
{
return employee::get_title();
}
void administration::print()
{
employee::print();
}
class acedemic :public employee
{
public:
acedemic(int cId, string cT, string name, int bday, int em = 0, int jy = 0,
string title = "") :employee(em, jy, title, cId, cT, name, bday)
{}
void print()
{
employee::print();
}
string getjobtitle()
{
employee::get_title();
}
void setCourseID(int s1)
{
employee::setCourseid(s1);
}
void setCourseTitle(string s2)
{
employee::setCoursetitle(s2);
}
};
int main()
{
int empid, jy1, yb;
string t, n;
cout << "ENTER EMPLOYEE ID:\t";
cin >> empid;
cout << "ENTER JOINING YEAR\t";
cin >> jy1;
cout << "ENTER JOB TITLE\t";
cin >> t;
cout << "ENTER NAME\t";
cin >> n;
cout << "ENTER YEAR OF BIRTH\t";
cin >> yb;
administration l(empid, jy1, t, n, yb);
l.print();
cout << "ENTER COURSE ID:\t";
cin >> empid;
cout << "ENTER COURSE TITLE\t";
cin >> t;
cout << "ENTER NAME\t";
cin >> n;
cout << "ENTER YEAR OF BIRTH\t";
cin >> yb;
acedemic a1(empid, t, n, yb);
a1.print();
system("pause");
return 0;
}

You might also like