Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

COS assignment 3

Rating
-
Sold
2
Pages
24
Uploaded on
20-08-2023
Written in
2023/2024

COS assignment 3

Institution
Module

Content preview

Question 1




// employee.h
#ifndef EMPLOYEE_H
#define EMPLOYEE_H

#include <string>

using namespace std;
class Employee
{
private:
string firstName;
string lastName;
float salary;

public:
// constructors
Employee();
Employee(string fName, string lName, float slry);

// mutators
void setFirstName(string fName);
void setLastName(string lName);
void setSalary(float slry);

// accessors
string getFirstName();
string getLastName();
float getSalary();

// destructor
~Employee();
};
#endif

,// employee.cpp
#include "employee.h"

Employee::Employee()
{
firstName = "";
lastName = "";
salary = 0;
}

Employee::Employee(string fName, string lName, float slry)
{
firstName = fName;
lastName = lName;
salary = slry;
}

void Employee::setFirstName(string fName)
{
firstName = fName;
}

void Employee::setLastName(string lName)
{
lastName = lName;
}

void Employee::setSalary(float slry)
{
salary = slry;
}

string Employee::getFirstName()
{
return firstName;
}



string Employee::getLastName()
{
return lastName;
}

float Employee::getSalary()
{
return salary;
}

Employee::~Employee()

, {
}
// question1.cpp
#include "employee.h"
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
Employee employee1("Joe", "Soap", 145600.00);
Employee employee2;

string fn, ln;
float slry;

cout << "Enter employee first name: ";
cin >> fn;
cout << "Enter employee last name: ";
cin >> ln;
cout << "Enter salary: ";
cin >> slry;

employee2.setFirstName(fn);
employee2.setLastName(ln);
employee2.setSalary(slry);

// Annual salary of each employee before raise
cout<<fixed<<setprecision(2);
cout << "Employee 1 annual salary: R" << employee1.getSalary() << endl;
cout << "Employee 2 annual salary: R" << employee2.getSalary() << endl;

// Adding the raise to the employees
cout << "Employee 1 annual salary with raise: R" <<
employee1.getSalary()*1.1 << endl;
cout << "Employee 2 annual salary with raise: R" <<
employee2.getSalary()*1.1 << endl;



return 0;
}

Written for

Institution
Module

Document information

Uploaded on
August 20, 2023
Number of pages
24
Written in
2023/2024
Type
OTHER
Person
Unknown

Subjects

£3.30
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
foxNotes Acsess Business Academy
Follow You need to be logged in order to follow users or courses
Sold
113
Member since
3 year
Number of followers
63
Documents
36
Last sold
3 weeks ago
saveNotes

5.0

5 reviews

5
5
4
0
3
0
2
0
1
0

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions