You are on page 1of 6

PRACTICE TASK 1

#include<iostream>
using namespace std;

class Person {
public:
string name;
int year_of_birth;
Person(string n, int y) {
name = n;
year_of_birth = y;
}
};

class Student :public Person {


public:
int studentID, encrolledSemester;
Student(string name, int year, int id, int enyear) :Person(name, year) {
studentID = id;
encrolledSemester = enyear;
}
void display() {
cout << "name=" << name << endl;
cout << "year of birth=" << year_of_birth << endl;
cout << "Student id=" << studentID << endl;
cout << "Encrolled semester=" << encrolledSemester << endl;
}
};

class Employee {
public:
int employeeID, joiningYear, courseID;
string jobTitle, courseTitle;
};

class Administration :public Employee {


public:
Administration(int empid, int joiningy, string jobt, int cid, string courset) {
employeeID = empid;
joiningYear = joiningy;
courseID = NULL;
jobTitle = jobt;
courseTitle = "";
}
void setJobTitle(string jobt) {
jobTitle = jobt;
}
string getJobTitle() {
return jobTitle;
}

};

class Academic :Employee {


public:
Academic(int empid, int joiningy, string jobt, int cid, string courset) {
employeeID = NULL;
joiningYear = NULL;
courseID = cid;
jobTitle = "";
courseTitle = courset;
}
void setCourseID(int id) {
courseID = id;
}
void setCourseTitle(string ct) {
courseTitle = ct;
}
};

int main() {

Person Q("Hasan", 2002);


Student S("John",2001, 5, 1);
S.display();
Administration ADM(1, 2020, "ceo", 1, "cse");
ADM.setJobTitle("Employee");
Academic A(1, 2020, "ceo", 1, "cse");
}

OUTPUT

PRACTICE TASK 2
#include<iostream>
using namespace std;

class Employee
{
protected:
int empid;
string empname;
public:
Employee(int id, string emp_name)
{
empname = emp_name;
empid = id;
}
};
class HourlyEmployee : public Employee
{
public:
int hourlyIncome;

public:
HourlyEmployee(int hour, int id, string emp_name) : Employee(id, emp_name)
{
hourlyIncome = hour;
}

void calculate_hourly_income()
{
cout << "Income of Hourly Employee is : " << hourlyIncome * 150 << endl;

void Display()
{
cout << "Hourly Employee ID : " << empid << endl;
cout << "Hourly Employee Name : " << empname << endl;

}
};

class PermanentEmployee : public Employee


{
public:
int hourlyIncome;

public:
PermanentEmployee(int hour, int id, string emp_name) : Employee(id, emp_name)
{
hourlyIncome = hour;
}

void income()
{
cout << "Income of Permanent Employee is : " << (hourlyIncome * 150) + 240 <<
endl;

void Display()
{
cout << "Permanent Employee ID : " << empid << endl;
cout << "Permanent Employee Name : " << empname << endl;

};

int main()
{
HourlyEmployee h(20, 564, "Hasan");
PermanentEmployee p(25, 670, "Hussain");
h.Display();
h.calculate_hourly_income();
p.Display();
p.income();

OUTPUT

PRACTICE TASK 3
#include <iostream>

using namespace std;

class BankAccount {

private:
int accountID;
int balance;

public:

BankAccount(int accountID, int balance) {


this->accountID = accountID;
this->balance = balance;
}

void setAccoutnId(int accountID) {


this->accountID = accountID;
}

int getAccountId() {
return accountID;
}
void setBalance(int balance) {
this->balance = balance;
}

int balanceInquiry() {
return balance;
}
};

class CurrentAccount : public BankAccount {

public:

CurrentAccount(int accountID, int balance) :BankAccount(accountID, balance) {

void Withdrawn(int amu) {


if ( balanceInquiry() - amu >= 5000)
setBalance(balanceInquiry() - amu);
}

void Deposit(int amu) {


setBalance(balanceInquiry() + amu);
}
};

class SavingsAccount : public BankAccount {

public:

SavingsAccount(int accountID, int balance) :BankAccount(accountID, balance) {

void Withdrawn(int amu) {


if ( balanceInquiry()-amu >= 10000)
setBalance(balanceInquiry() - amu);
}

void Deposit(int amu) {


setBalance(balanceInquiry() + amu);
}

};

int main()
{

cout << "Current Account : " << endl;


CurrentAccount current(2, 70000);
current.Withdrawn(65000);
cout << " balance after withdraw : ";
cout << current.balanceInquiry() << endl;
current.Deposit(30000);
cout << " balance after deposit : ";
cout << current.balanceInquiry() << endl;
cout << endl;
cout << "Savings Account " << endl;
SavingsAccount saving(5, 80000);
saving.Withdrawn(10000);
cout << " balance after withdraw : ";
cout << saving.balanceInquiry() << endl;
saving.Deposit(20000);
cout << " balance after deposit : ";
cout << saving.balanceInquiry();

return 0;
}

OUTPUT

You might also like