Here's a partial program to help you out. Read it, try to understand it, and see if you can finish your assignment.
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
class Employee
{
public:
Employee(); //Default with no name and no salary
Employee(string eName, int eSalary); //create with name...
void input();
void output() const;
void computeNewSalary(int raisepercentage);
private:
string _name;
int _salary;
};
//Default constructor
Employee::Employee()
{
_name = "";
_salary = 0;
}
//Constructor with name/salary
Employee::Employee(string eName, int eSalary)
{
_name = eName;
_salary = eSalary;
}
//Set name and salary
void Employee::input()
{
cout << "Enter name and salary: ";
cin >> _name >> _salary;
}
//output, should be "const" as it is not changing any variables
void Employee::output() const
{
cout << "Name: " << _name << endl << "Salary: " << _salary << endl;
}
//Raise salary within your object
void Employee::computeNewSalary(int raisepercentage)
{
_salary = _salary * (raisepercentage/100.0);
}
int main()
{
//Create default object
Employee me;
//Set name and salary
me.input();
//Print out name and salary
me.output();
//Raise salary
me.computeNewSalary(150);
me.output();
return EXIT_SUCCESS;
}