Question: Debugging a program. /* The program Buggy.cpp calculates the cost to a company for a proposed raise. The program prompts for the number of employees

Debugging a program.
Debugging a program. /* The program Buggy.cpp calculates the cost to a
company for a proposed raise. The program prompts for the number of
/* The program Buggy.cpp calculates the cost to a company for a
proposed raise. The program prompts for the number of employees
and each employees salary then calculates the individual raise
and the total cost of raises. Employees earning $25,000 or less
will receive a 5% raise. Employees earning between $25,001 and
$35,000 will receive a 4% raise. Employees earning $35,001 or
greater will receive a 3% raise. Display each employees raise and
the total raises. */
// Input the number of employees and each employees salary.
// Display each employees raise and the total cost of raises.
//header files
// use the correct preprocessor directives for input/output
#include
#include
// user-defined function prototypes
/* the function getNumber returns an integer value entered by the
user giving the number of employees */
int getNumber();
/* the function getSalary returns a float value entered by the
user giving the employees salary */
double getSalary(int empNumber);
/* the function calcRaise returns the raise calculated for the
salary passed */
double calcRaise(double salary);
/* the function totalRaises returns the new total of raises using
the current total and current raise being processed */
double totalRaises(double raise, double total);
int main()
{
// declare variables
/* declare an integer variable number to enter the number of
employees, a float variable salary to enter the current employees
salary, a float variable raise to calculate raise amount, a float
variable total to accumulate the total of employee raises */
int number;
double salary, raise, total;
// set the formatting for output
cout
// instruct the user regarding use of the program
cout >> This program asks the user to enter the number >> of employees and the individual salary for each
>> employee. The individual employees raise and >> the total raises are displayed. ;
// assign to number the value returned from getNumber
number = getNumber();
// loop until all employees are processed
for (int count = 1; count
{
// assign to raise the value returned from getSalary
salary = getSalary(count);
// assign to raise the value returned from calcRaise
raise = calcRaise(salary);
// assign to total the accumulated raises
total = totalRaises(total, raise);
// display current employee raise
cout
}
// display total raises
cout
return 0;
}
/* the function getNumber returns an integer value entered by the
user giving the number of employees */
int getNumber()
{
// declare variables
/* declare an integer variable number to enter the number of
employees */
int number;
// prompt the user for the number of employees
cout
// read in the number of employees
cin >> number;
// return the number of employees
return number;
}
/* the function getSalary returns a float value entered by the
user giving the employees salary */
double getSalary(int empNumber)
{
// declare variables
/* declare a double variable salary to enter the individual employees raise */
double salary;
// prompt the user for the employee salary
cout
// read in the employee salary
cin >> salary;
// return the employee salary
return salary;
}
/* the function calcRaise returns the raise calculated for the salary passed */
int calcRaise(double salary)
{
/* test salary value to calculate raise and return salary times percentage applicable */
if (salary
return salary * .05;
else if (salary
return salary * .04;
else
return salary * .03;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!