0% found this document useful (0 votes)
31 views6 pages

Cs304 Assignment 2 Solution Fall 2024 by VuCopier

Uploaded by

Jehanzaib khalil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views6 pages

Cs304 Assignment 2 Solution Fall 2024 by VuCopier

Uploaded by

Jehanzaib khalil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

For Paid Assignment Solutions

WhatsApp now 03086278790


Solution by VuCopier

Cs304 Assignment No. 02


SEMESTER Fall 2024 VuCopier
VuCopier1.gmail.com For More Updates Visit
By VuCopier Vucopier.blogspot.com
0308-6278790

*** Contact for Paid Services ***


All Departments LMS Handling
All Subjects Assignments
All Subjects Quiz
All Subjects GDB

Join WhatsApp Group


https://chat.whatsapp.com/JwPEnqfqxhLB65qsO7ysoC

#include <iostream>
#include <iomanip>
using namespace std;

// Abstract class Employee


class Employee {
protected:
int employeeId;
string employeeName;
double salary;

public:
Employee() : employeeId(0), employeeName(""),
salary(0.0) {}
Visit
Vucopier.blogspot.com
For Paid Assignment Solutions
WhatsApp now 03086278790
Solution by VuCopier

virtual void calculateSalary() = 0; // Pure virtual


function
virtual void displaySalary() const = 0;
virtual ~Employee() {}
};

// Regular Employee class


class RegularEmployee : public Employee {
private:
double basicSalary;
double allowances;
double incomeTax;

public:
RegularEmployee(int id, string name, double basic,
double allow, double tax) {
employeeId = id;
employeeName = name;
basicSalary = basic;
allowances = allow;
incomeTax = tax;
}

void calculateSalary() override {


salary = basicSalary + allowances - incomeTax;
}

void displaySalary() const override {


Visit
Vucopier.blogspot.com
For Paid Assignment Solutions
WhatsApp now 03086278790
Solution by VuCopier

cout << "Salary of Regular Employee with basic pay:


" << basicSalary
<< ", allowances: " << allowances << " and
income tax: " << incomeTax
<< " is given below:\n" << salary << endl;
}
};

// Hourly Employee class


class HourlyEmployee : public Employee {
private:
double noOfHours;
double hourlyRate;

public:
HourlyEmployee(int id, string name, double hours,
double rate) {
employeeId = id;
employeeName = name;
noOfHours = hours;
hourlyRate = rate;
}

void calculateSalary() override {


salary = noOfHours * hourlyRate;
}

void displaySalary() const override {


Visit
Vucopier.blogspot.com
For Paid Assignment Solutions
WhatsApp now 03086278790
Solution by VuCopier

cout << "Salary of Hourly Employee with hourly


rate: " << hourlyRate
<< " and no. of hours: " << noOfHours << " is
given below:\n" << salary << endl;
}
};

int main() {
// Create objects using Dataset
RegularEmployee regular(1, "Alice", 60000, 20000,
5000);
HourlyEmployee hourly(2, "Bob", 20, 3000);

// Calculate salaries
regular.calculateSalary();
hourly.calculateSalary();

// Display results
regular.displaySalary();
cout << endl;
hourly.displaySalary();

return 0;
}

Visit
Vucopier.blogspot.com
For Paid Assignment Solutions
WhatsApp now 03086278790
Solution by VuCopier

*** Contact for Paid Services ***


All Departments LMS Handling
All Subjects Assignments
All Subjects Quiz
All Subjects GDB

For More Updates


Join WhatsApp Group
https://chat.whatsapp.com/JwPEnqfqxhLB65qsO7ysoC

Visit
Vucopier.blogspot.com
For Paid Assignment Solutions
WhatsApp now 03086278790
Solution by VuCopier

VuCopier

Visit
Vucopier.blogspot.com

You might also like