find the inputs and outputs, write the pseudocode, desk check the pseudocode ,cr
ID: 3688943 • Letter: F
Question
find the inputs and outputs, write the pseudocode, desk check the pseudocode ,create the flowchart, and code the solutionin C++
A company wants a system to compute an employee’s end - of - year bonus and then output the employee’s n ame, yearly salary, performance rating and bonus. The bonus is based on rating received and salary as shown in the table below. The program should allow the company to enter as many employees as they wish and to display the average of the bonus es given to the employees . The program will quit if a given sentinel value is entered.
Rating Bonus
1 25 percent of the yearly salary
2 15 percent of the yearly salary
3 10 percent of the yearly salary
4 No bonus given
Explanation / Answer
#include <iostream>
#include <iomanip>
#include<string>
using namespace std;
class Employee
{
private:
int empno;
string name;
double salary;
int grade;
double bonus;
public:
void setBonus(double b)
{
bonus=b;
}
void setGrade(int g)
{
grade=g;
}
void setSalary(double s)
{
salary=s;
}
void setName(string n)
{
name=n;
}
void setEmpNo(int no)
{
empno=no;
}
double getBonus()
{
return bonus;
}
int getGrade()
{
return grade;
}
double getSalary()
{
return salary;
}
string getName()
{
return name;
}
int getEmpNo()
{
return empno;
}
double calculateBonus()
{
if(grade==1)
bonus=0.4*salary;
else if(grade==2)
bonus=0.15*salary;
else if(grade==3)
bonus=0.1*salary;
else if(grade==4)
bonus=0;
return bonus;
}
};
int main()
{
int flag=1,count=0;
Employee emp[10];
string name;
double salary,bonus;
int empno,grade;
char status;
cout << "Welcome to Employee Bonus Calculation" << endl;
while(flag==1)
{
cout<<"enter employee details. Press E to enter Q to quit: ";
cin>>status;
if(tolower(status)=='q')
{
flag=0;
break;
}
else
{
cout<<"enter emp's name: ";
cin>>name;
cout<<"enter emp's no: ";
cin>>empno;
cout<<"enter emp's salary: ";
cin>>salary;
cout<<"enter emp's rating: ";
cin>>grade;
if(grade>0 && grade<5)
emp[count].setName(name);
emp[count].setEmpNo(empno);
emp[count].setGrade(grade);
emp[count].setSalary(salary);
emp[count].setBonus(emp[count].calculateBonus());
count++;
}
}
if(count>0)
{
double avg=0.0;
cout<<" Name EmpNo Salary Rating Bonus ";
for(int i=0;i<count;i++)
{
cout<<emp[i].getName()<<" "<<emp[i].getEmpNo()<<" "<<emp[i].getSalary()<<" "<<emp[i].getGrade()<<" "<<emp[i].getBonus()<<" "<<endl;
avg+=emp[i].getBonus();
}
cout<<" Average Bonususes given is: "<<setprecision(2)<<avg/count<<endl;
}
else
cout<<"You don't have any employees!Please hire some."<<endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.