This programm is asking the employee to inter her or his job category
e.g"Technical Staff" or "Administration Staff" then the program should ask the years the employee has worked if the employee entered a "Technical Staff" category then the program should calculate the salary increase else it should further as the user the exact department that the employee is in e.g Marketing or Accounting then calculate the salary.
I have created this code
cout<<"What type of staff are you? ";
cin>>category;
getline(cin,category,'\n');
cout<<"Enter your current salary: ";
cin>>salary;
if(category=="Technical Staff")
{
cout<<"How may years have you worked here? ";
#include"stdafx.h"
#include<iostream>
#include<string>
usingnamespace std;
int main()
{
string category,department;
int years;
double salary;
cout<<"What type of staff are you? ";
getline(cin,category,'\n');
cout<<"Enter your current salary: ";
cin>>salary;
cout<<"How may years have you worked here? ";
cin>>years;
cout<<"Which department are you working for? ";
cin.ignore();
getline(cin,department,'\n');
if(category=="Technical Staff")
{
if(years>10)
salary=salary+salary*0.05;
else
salary=salary+salary*0.03;
}
elseif (category=="Administrative Staff")
{
if(department=="Account Department")
salary=salary+salary*0.06;
elseif(department=="Marketing Department")
salary=salary+salary*0.04;
else
salary=salary+salary*0.03;
}
else
salary=salary+salary*0.02;
cout<<"You are a "<<category<<endl;
cout<<"You have worked for "<<years<<endl;
cout<<"you are in "<<department<<endl;
cout.setf(ios::fixed);
cout.precision(2);
cout<<"Your salary is R "<<salary<<endl;
system("pause");
return 0;
}
Please next time be careful mention your variable type..
you have to use string data type
string category,department;
double salary,years;
cout<<"What type of staff are you? ";
getline(cin,category,'\n');
cout<<"Enter your current salary: ";
cin>>salary;
I just started using VC++ from tomorrow.Untill then I was using Turbo c++.
So if any error occur tell me so I can test it in Turbo c++.and improve my VC++ experience.