Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CSCE 1030: Project 2 Spring 2018 Due: Monday, 02/26 11.59 PM PROGRAM DESCRIPTION

ID: 3709254 • Letter: C

Question

CSCE 1030: Project 2 Spring 2018 Due: Monday, 02/26 11.59 PM PROGRAM DESCRIPTION: In this project, you will write a program to calculate the bonus and the total salary of an employee in a company, among other things. Here is how the company evaluates bonus for an employee. There are three categories of employees- Executive, Manager and Staff For executives, the bonus policy is A minimum bonus of $10000.00 is Additional bonus depends on the years of experience and a lottery system. e If years of experience is more than 20 years, the employee gets 15%-20% (inclusive) of the salary as bonus. If years of experience is more than 10 years and less than or equal to 20 years, the employee gets 10%-15% (inclusive) of the salary as bonus. If years of experience is less than 10 years, the employee gets 5%-10% (inclusive) of the salary as bonus. The exact % of the additional bonus is obtained by using a random lottery pick. o o o For managers, the bonus policy is: minimum bonus of S5000.00 is Additional bonus depends on the years of experience and a lottery system. A . o If years of experience is more than 20 years, the employee gets 10%-15% (inclusive) of the salary as bonus. If years of experience is more than 10 years and less than or equal to 20 years, the employee gets 5%-10% (inclusive) of the salary as bonus. If years of experience is less than 10 years, the employee gets 1%-5% (inclusive) of the salary as bonus. The exact % of the additional bonus is obtained by using a random lottery pick. o For staffs, the policy is: A minimum bonus of $1000.00 is guaranteed. Additional bonus depends on the years of experience and a lottery system. If years of experience is more than 20 years, the employee gets 5%-10% (inclusive) of the salary as bonus If years of experience is more than 10 years and less than or equal to 20 years, the employee gets 1%-5% (inclusive) ofthe salary as bonus. If years of experience is less than 10 years, there is no additional bonus The exact % of the additional bonus is obtained by using a random lottery pick. o o o

Explanation / Answer

Executable code

#include <iostream>

using namespace std;

int main()
{
char name[100],ch;
int yr,role,e=0,m=0,s=0;
double payout=0,sal,bonus,additional,total=0;


do
{
cout<<" Enter full name of the employee : ";
cin.getline(name,100);


name[0] = toupper(name[0]);
for (int i = 1; i < 100; i++)
{
if ( name[i - 1] == ' ' )
name[i] = toupper( name[i] );
}
cout<<"Enter number of year of experience : ";
cin>>yr;
cout<<"Enter salary of the employee : ";
cin>>sal;


Loop:
cout<<"Enter role of the employee : ";
cout<<"1.Executive";
cout<<" 2.Manager";
cout<<" 3.Staff ";
cin>>role;

switch(role)
{
case 1 :e++;
bonus=10000;
if(yr>20)
bonus=bonus+((15/100)*sal);
if(yr>10 && yr<=20)
bonus=bonus+((10/100)*sal);
if(yr<=10)
bonus=bonus+((5/100)*sal);

srand((unsigned)time(0));
additional=rand()%20;
break;
case 2: m++;
bonus=5000;
if(yr>20)
bonus=bonus+((10/100)*sal);
if(yr>10 && yr<=20)
bonus=bonus+((5/100)*sal);
if(yr<=10)
bonus=bonus+((1/100)*sal);
srand((unsigned)time(0));
additional=rand()%20;
break;
case 3 : s++;
bonus=1000;
if(yr>20)
bonus=bonus+((5/100)*sal);
if(yr>10 && yr<=20)
bonus=bonus+((1/100)*sal);
if(yr<=10)
bonus=bonus+0;
srand((unsigned)time(0));
additional=rand()%20;
break;
default : cout<<"Wrong roll number, Enter again";
goto Loop;
break;
}

payout=(sal+bonus+((additional/100)*sal));


total=total+payout;
cout<<" "<<name<<" obtained a total payout of $"<<payout<<" "<<additional;
cout<<" Another employee ? press 'n' or 'N' to stop, any other key to continue : ";
cin>>ch;
cin.ignore();
if(ch=='n')
ch=toupper(ch);
}while( ch!='N');

cout<<" Total executive processed : "<<e;
cout<<" Total manager processed : "<<m;
cout<<" Total staff processed : "<<s;
cout<<" Total company payout : $"<<total;
return 0;
}