100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 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
Course










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

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

Subjects

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;
}

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
112
Member since
2 year
Number of followers
63
Documents
35
Last sold
3 months ago
saveNotes

5.0

5 reviews

5
5
4
0
3
0
2
0
1
0

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 tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right 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 aced it. It really can be that simple.”

Alisha Student

Frequently asked questions