A-1-3-26) DISPLAY employee number preceded by newline and tab escape sequence
A-1-3-27) followed by tab escape sequence, dollar sign literal, FIXED, SHOWPOINT SETPRECISION of 2
A-1-3-2 followed by value of employeeGrossPay at index employeeNumber – 1 (Exhibit Z, lines 19, 20 and 21)
A-1-3-29) INCREMENT employeeNumbe
/* // A-1-1-01
Author: Shawn Main // A-1-1-02
Date Written: December 11, 2011 // A-1-1-02
Course: CSIS 123, Internet // A-1-1-02
Program: Task 06-02, Chapter 4 // A-1-1-02
Program Description: This test, or driver, program, which demonstrates the "while" // A-1-1-02
repetition statement, determines gross pay for each of // A-1-1-02
several employees. The organization pays "straight time" for // A-1-1-02
the first 40 hours worked by each employee and pays // A-1-1-02
"time-and-a-half" for all hours worked in excess of 40 hours. // A-1-1-02
The program prompts the user for hours worked and hourly pay rate // A-1-1-02
for three employees and, from that information, calculates gross // A-1-1-02
pay. A list of employee number and gross pay is displayed after // A-1-1-02
all input as been accepted. // A-1-1-02
Compiler Used: Microsoft Visual C++ 2010 Express // A-1-1-02
SourceFile Name: Payroll.cpp // A-1-1-02
*/ // A-1-1-03
#include <iostream> // A-1-1-04
#include <iomanip> // A-1-1-05 TODO
#include <string> // A-1-1-06
using namespace std; // A-1-1-07
class Payroll { // A-1-1-08
public: // A-1-1-09
void calculateCurrentPayroll() { // A-1-1-10
const double c_maximumHoursWorkedWithoutOvertimePay = 40; // A-1-3-01 TODO
const static int c_inputPromptWidth = 17; // A-1-3-02 TODO
double grossPay; // A-1-3-03
double hoursWorked; // A-1-3-04 TODO
double hourlyPayRate; // A-1-3-05 TODO
const double c_overtimePayRatePremium = 1.5; // A-1-3-06 TODO
int employeeNumber = 1; // A-1-3-07
while (employeeNumber <= getEmployeeCount()) { // A-1-3-08
cout << "\n\tEnter employee", employeeNumber; // A-1-3-09 TODO
cout << "\n\t\tHours Worked"; // A-1-3-10 TODO
cin >> hoursWorked; // A-1-3-11 TODO
cout << "\n\t\tHourly Pay Rate"; // A-1-3-12 TODO
cin >> hourlyPayRate; // A-1-3-13 TODO
if (hoursWorked <= 40) // A-1-3-14 TODO
grossPay = hoursWorked * hourlyPayRate; // A-1-3-15 TODO
else // A-1-3-16 TODO
grossPay = c_maximumHoursWorkedWithoutOvertimePay * hourlyPayRate // A-1-3-17 TODO
+ hoursWorked - c_maximumHoursWorkedWithoutOvertimePay // A-1-3-18 TODO
* hourlyPayRate * c_overtimePayRatePremium; // A-1-3-19 TODO
// // A-1-3-20 TODO
employeeGrossPay[employeeNumber - 1] = grossPay; // A-1-3-21
employeeNumber++; // A-1-3-22
}// while // A-1-3-23
} // function calculateCurrentPayroll // A-1-1-11
void displayCurrentPayroll() { // A-1-1-12
int employeeNumber = 1; // A-1-3-24 TODO
employeeNumber <= getEmployeeCount(); // A-1-3-25 TODO
cout << "\n\temployee number" // A-1-3-26 TODO
"\t" << fixed << showpoint << setprecision(2); // A-1-3-27 TODO
cout << employeeGrossPay[employeeNumber - 1]; // A-1-3-28 TODO
employeeNumber++; // A-1-3-29 TODO
} // A-1-3-30 TODO
// function displayCurrentPayroll // A-1-1-13
int getEmployeeCount() { // A-1-1-14
return c_employeeCount; // A-1-3-31
} // function getEmployeeCount // A-1-1-15
private: // A-1-1-16
const static int c_employeeCount = 3; // A-1-1-17
double employeeGrossPay[c_employeeCount]; // A-1-1-18
}; // class Payroll // A-1-1-19
int main() { // A-1-5-01
Payroll currentPayroll; // A-1-5-02 TODO
string enterKey; // A-1-5-03
cout << "\nTask 06-02, Ch04, Programmed by Shawn Main"; // A-1-5-04
cout << "\n\nProgram Input:"; // A-1-5-05
currentPayroll.calculateCurrentPayroll(); // A-1-5-06 TODO
cout << "\nProgram Output:"; // A-1-5-07 TODO
cout << "\n\t # Gross Pay"; // A-1-5-08 TODO
currentPayroll.displayCurrentPayroll(); // A-1-5-09 TODO
rewind( stdin ); // A-1-5-10 TODO
cout << "\n\nEnd of program: Press <Enter> key to exit program."; // A-1-5-11
getline(cin, enterKey); // A-1-5-12
} // function main // A-1-5-13
A-1-3-01) DECLARE local named constant double variable named c_maximumHoursWorkedWithoutOvertimePay with a value of 40.0
A-1-3-02) DECLARE local named constant int variable named c_inputPromptWidth with a value of 17
A-1-3-03) DECLARE local double variable named grossPay
A-1-3-04) DECLARE local double variable named hoursWorked
A-1-3-05) DECLARE local double variable named hourlyPayRate
A-1-3-06) DECLARE local named constant double variable named c_overtimePayRatePremium with a value of 1.5
A-1-3-07) DECLARE local int variable named employeeNumber with an initial value of 1
REPETITION HEADER:
A-1-3-0 while employeeNumber is less than or equal getEmployeeCount(), followed by opening brace for body of loop
A-1-3-09) DISPLAY input-prompt-header for employee, preceded by newline and tab escape sequence, follow by employeeNumber and colon (Exhibit Z, lines 5, 9 and 13)
A-1-3-10) DISPLAY hours-worked prompt, preceded by newline and 2 tab escape sequences, COLUMN WIDTH for input prompt, RIGHT JUSTIFICATION (Exhibit Z, lines 6, 10 and 14)
A-1-3-11) ACCEPT user keyboard input for hours worked (Exhibit Z, lines 6, 10 and 14)
A-1-3-12) DISPLAY hourly-pay-rate prompt, preceded by 2 tab escape sequences, COLUMN WIDTH for input prompt, RIGHT JUSTIFICATION (Exhibit Z, lines 7, 11 and 15)
A-1-3-13) ACCEPT user keyboard input for hourly pay rate (Exhibit Z, lines 7, 11 and 15)
DOUBLE-ALTERNATIVE IF HEADER:
A-1-3-14) IF employee did not work overtime THEN
A-1-3-15) ASSIGN value of expression (hoursWorked MULTIPLIED BY hourlyPayRate) TO variable grossPay
A-1-3-16) ELSE
A-1-3-17) ASSIGN value of expression (c_maximumHoursWorkedWithoutOvertimePay MULTIPLIED BY hourlyPayRate
A-1-3-1 PLUS (hoursWorked MINUS c_maximumHoursWorkedWithoutOvertimePay)
A-1-3-19) MULTIPLIED BY hourlyPayRate MULTIPLIED BY c_overtimePayRatePremium) TO grossPay
DOUBLE-ALTERNATIVE IF FOOTER:
A-1-3-20) Enter closing comment for double-alternative if statement
A-1-3-21) ASSIGN value of grossPay TO array element of employeeGrossPay at index employeeNumber - 1
A-1-3-22) INCREMENT employeeNumber
REPETITION FOOTER:
A-1-3-23) Enter closing brace for body of loop
A-1-3-24) DECLARE local int variable named employeeNumber with an initial value of 1
REPETITION HEADER:
A-1-3-25) while employeeNumber is less than or equal getEmployeeCount(), followed by opening brace for body of loop
Display the one-line detail for each employee
A-1-3-26) DISPLAY employee number preceded by newline and tab escape sequence
A-1-3-27) followed by tab escape sequence, dollar sign literal, FIXED, SHOWPOINT SETPRECISION of 2
A-1-3-2 followed by value of employeeGrossPay at index employeeNumber – 1 (Exhibit Z, lines 19, 20 and 21)
A-1-3-29) INCREMENT employeeNumber
REPETITION FOOTER:
A-1-3-30) Enter closing brace for body of loop
A-1-3-31) RETURN value of data member c_employeeCount
A-1-5-01) Enter function header for function main and opening brace for function’s body
A-1-5-02) DECLARE local Payroll object named currentPayroll
A-1-5-03) DECLARE local string variable named enterKey
A-1-5-04) DISPLAY task-id-and-programmer-identification line, placing newline escape sequence before line (Exhibit Z, lines 1 and 2)
A-1-5-05) DISPLAY program-input-heading line, placing 2 newline escape sequences before line (Exhibit Z, lines 3 and 4)
A-1-5-06) CALL currentPayroll object’s calculateCurrentPayroll public member function
A-1-5-07) DISPLAY program-output-heading line, placing newline escape sequence before line (Exhibit Z, lines 16 and 17)
A-1-5-0 DISPLAY column heading line, placing newline and tab escape sequence before 1st column heading and tab escape sequence before 2nd (Exhibit Z, line 1
A-1-5-09) CALL currentPayroll object’s displayCurrentPayroll public member function
A-1-5-10) CLEAR keyboard buffer
A-1-5-11) DISPLAY end-of-program output line, placing 2 newline escape sequences before line (Exhibit Z, lines 22 and 23)
A-1-5-12) CLEAR keyboard buffer
A-1-5-13) Enter closing brace for body of function main
A-1-3-26) DISPLAY employee number preceded by newline and tab escape sequence
A-1-3-27) followed by tab escape sequence, dollar sign literal, FIXED, SHOWPOINT SETPRECISION of 2
A-1-3-2 followed by value of employeeGrossPay at index employeeNumber – 1 (Exhibit Z, lines 19, 20 and 21)
A-1-3-29) INCREMENT employeeNumbe
/* // A-1-1-01
Author: Shawn Main // A-1-1-02
Date Written: December 11, 2011 // A-1-1-02
Course: CSIS 123, Internet // A-1-1-02
Program: Task 06-02, Chapter 4 // A-1-1-02
Program Description: This test, or driver, program, which demonstrates the "while" // A-1-1-02
repetition statement, determines gross pay for each of // A-1-1-02
several employees. The organization pays "straight time" for // A-1-1-02
the first 40 hours worked by each employee and pays // A-1-1-02
"time-and-a-half" for all hours worked in excess of 40 hours. // A-1-1-02
The program prompts the user for hours worked and hourly pay rate // A-1-1-02
for three employees and, from that information, calculates gross // A-1-1-02
pay. A list of employee number and gross pay is displayed after // A-1-1-02
all input as been accepted. // A-1-1-02
Compiler Used: Microsoft Visual C++ 2010 Express // A-1-1-02
SourceFile Name: Payroll.cpp // A-1-1-02
*/ // A-1-1-03
#include <iostream> // A-1-1-04
#include <iomanip> // A-1-1-05 TODO
#include <string> // A-1-1-06
using namespace std; // A-1-1-07
class Payroll { // A-1-1-08
public: // A-1-1-09
void calculateCurrentPayroll() { // A-1-1-10
const double c_maximumHoursWorkedWithoutOvertimePay = 40; // A-1-3-01 TODO
const static int c_inputPromptWidth = 17; // A-1-3-02 TODO
double grossPay; // A-1-3-03
double hoursWorked; // A-1-3-04 TODO
double hourlyPayRate; // A-1-3-05 TODO
const double c_overtimePayRatePremium = 1.5; // A-1-3-06 TODO
int employeeNumber = 1; // A-1-3-07
while (employeeNumber <= getEmployeeCount()) { // A-1-3-08
cout << "\n\tEnter employee", employeeNumber; // A-1-3-09 TODO
cout << "\n\t\tHours Worked"; // A-1-3-10 TODO
cin >> hoursWorked; // A-1-3-11 TODO
cout << "\n\t\tHourly Pay Rate"; // A-1-3-12 TODO
cin >> hourlyPayRate; // A-1-3-13 TODO
if (hoursWorked <= 40) // A-1-3-14 TODO
grossPay = hoursWorked * hourlyPayRate; // A-1-3-15 TODO
else // A-1-3-16 TODO
grossPay = c_maximumHoursWorkedWithoutOvertimePay * hourlyPayRate // A-1-3-17 TODO
+ hoursWorked - c_maximumHoursWorkedWithoutOvertimePay // A-1-3-18 TODO
* hourlyPayRate * c_overtimePayRatePremium; // A-1-3-19 TODO
// // A-1-3-20 TODO
employeeGrossPay[employeeNumber - 1] = grossPay; // A-1-3-21
employeeNumber++; // A-1-3-22
}// while // A-1-3-23
} // function calculateCurrentPayroll // A-1-1-11
void displayCurrentPayroll() { // A-1-1-12
int employeeNumber = 1; // A-1-3-24 TODO
employeeNumber <= getEmployeeCount(); // A-1-3-25 TODO
cout << "\n\temployee number" // A-1-3-26 TODO
"\t" << fixed << showpoint << setprecision(2); // A-1-3-27 TODO
cout << employeeGrossPay[employeeNumber - 1]; // A-1-3-28 TODO
employeeNumber++; // A-1-3-29 TODO
} // A-1-3-30 TODO
// function displayCurrentPayroll // A-1-1-13
int getEmployeeCount() { // A-1-1-14
return c_employeeCount; // A-1-3-31
} // function getEmployeeCount // A-1-1-15
private: // A-1-1-16
const static int c_employeeCount = 3; // A-1-1-17
double employeeGrossPay[c_employeeCount]; // A-1-1-18
}; // class Payroll // A-1-1-19
int main() { // A-1-5-01
Payroll currentPayroll; // A-1-5-02 TODO
string enterKey; // A-1-5-03
cout << "\nTask 06-02, Ch04, Programmed by Shawn Main"; // A-1-5-04
cout << "\n\nProgram Input:"; // A-1-5-05
currentPayroll.calculateCurrentPayroll(); // A-1-5-06 TODO
cout << "\nProgram Output:"; // A-1-5-07 TODO
cout << "\n\t # Gross Pay"; // A-1-5-08 TODO
currentPayroll.displayCurrentPayroll(); // A-1-5-09 TODO
rewind( stdin ); // A-1-5-10 TODO
cout << "\n\nEnd of program: Press <Enter> key to exit program."; // A-1-5-11
getline(cin, enterKey); // A-1-5-12
} // function main // A-1-5-13
A-1-3-01) DECLARE local named constant double variable named c_maximumHoursWorkedWithoutOvertimePay with a value of 40.0
A-1-3-02) DECLARE local named constant int variable named c_inputPromptWidth with a value of 17
A-1-3-03) DECLARE local double variable named grossPay
A-1-3-04) DECLARE local double variable named hoursWorked
A-1-3-05) DECLARE local double variable named hourlyPayRate
A-1-3-06) DECLARE local named constant double variable named c_overtimePayRatePremium with a value of 1.5
A-1-3-07) DECLARE local int variable named employeeNumber with an initial value of 1
REPETITION HEADER:
A-1-3-0 while employeeNumber is less than or equal getEmployeeCount(), followed by opening brace for body of loop
A-1-3-09) DISPLAY input-prompt-header for employee, preceded by newline and tab escape sequence, follow by employeeNumber and colon (Exhibit Z, lines 5, 9 and 13)
A-1-3-10) DISPLAY hours-worked prompt, preceded by newline and 2 tab escape sequences, COLUMN WIDTH for input prompt, RIGHT JUSTIFICATION (Exhibit Z, lines 6, 10 and 14)
A-1-3-11) ACCEPT user keyboard input for hours worked (Exhibit Z, lines 6, 10 and 14)
A-1-3-12) DISPLAY hourly-pay-rate prompt, preceded by 2 tab escape sequences, COLUMN WIDTH for input prompt, RIGHT JUSTIFICATION (Exhibit Z, lines 7, 11 and 15)
A-1-3-13) ACCEPT user keyboard input for hourly pay rate (Exhibit Z, lines 7, 11 and 15)
DOUBLE-ALTERNATIVE IF HEADER:
A-1-3-14) IF employee did not work overtime THEN
A-1-3-15) ASSIGN value of expression (hoursWorked MULTIPLIED BY hourlyPayRate) TO variable grossPay
A-1-3-16) ELSE
A-1-3-17) ASSIGN value of expression (c_maximumHoursWorkedWithoutOvertimePay MULTIPLIED BY hourlyPayRate
A-1-3-1 PLUS (hoursWorked MINUS c_maximumHoursWorkedWithoutOvertimePay)
A-1-3-19) MULTIPLIED BY hourlyPayRate MULTIPLIED BY c_overtimePayRatePremium) TO grossPay
DOUBLE-ALTERNATIVE IF FOOTER:
A-1-3-20) Enter closing comment for double-alternative if statement
A-1-3-21) ASSIGN value of grossPay TO array element of employeeGrossPay at index employeeNumber - 1
A-1-3-22) INCREMENT employeeNumber
REPETITION FOOTER:
A-1-3-23) Enter closing brace for body of loop
A-1-3-24) DECLARE local int variable named employeeNumber with an initial value of 1
REPETITION HEADER:
A-1-3-25) while employeeNumber is less than or equal getEmployeeCount(), followed by opening brace for body of loop
Display the one-line detail for each employee
A-1-3-26) DISPLAY employee number preceded by newline and tab escape sequence
A-1-3-27) followed by tab escape sequence, dollar sign literal, FIXED, SHOWPOINT SETPRECISION of 2
A-1-3-2 followed by value of employeeGrossPay at index employeeNumber – 1 (Exhibit Z, lines 19, 20 and 21)
A-1-3-29) INCREMENT employeeNumber
REPETITION FOOTER:
A-1-3-30) Enter closing brace for body of loop
A-1-3-31) RETURN value of data member c_employeeCount
A-1-5-01) Enter function header for function main and opening brace for function’s body
A-1-5-02) DECLARE local Payroll object named currentPayroll
A-1-5-03) DECLARE local string variable named enterKey
A-1-5-04) DISPLAY task-id-and-programmer-identification line, placing newline escape sequence before line (Exhibit Z, lines 1 and 2)
A-1-5-05) DISPLAY program-input-heading line, placing 2 newline escape sequences before line (Exhibit Z, lines 3 and 4)
A-1-5-06) CALL currentPayroll object’s calculateCurrentPayroll public member function
A-1-5-07) DISPLAY program-output-heading line, placing newline escape sequence before line (Exhibit Z, lines 16 and 17)
A-1-5-0 DISPLAY column heading line, placing newline and tab escape sequence before 1st column heading and tab escape sequence before 2nd (Exhibit Z, line 1
A-1-5-09) CALL currentPayroll object’s displayCurrentPayroll public member function
A-1-5-10) CLEAR keyboard buffer
A-1-5-11) DISPLAY end-of-program output line, placing 2 newline escape sequences before line (Exhibit Z, lines 22 and 23)
A-1-5-12) CLEAR keyboard buffer
A-1-5-13) Enter closing brace for body of function main
/* // A-1-1-01
Author: Shawn Main // A-1-1-02
Date Written: December 11, 2011 // A-1-1-02
Course: CSIS 123, Internet // A-1-1-02
Program: Task 06-02, Chapter 4 // A-1-1-02
Program Description: This test, or driver, program, which demonstrates the "while" // A-1-1-02
repetition statement, determines gross pay for each of // A-1-1-02
several employees. The organization pays "straight time" for // A-1-1-02
the first 40 hours worked by each employee and pays // A-1-1-02
"time-and-a-half" for all hours worked in excess of 40 hours. // A-1-1-02
The program prompts the user for hours worked and hourly pay rate // A-1-1-02
for three employees and, from that information, calculates gross // A-1-1-02
pay. A list of employee number and gross pay is displayed after // A-1-1-02
all input as been accepted. // A-1-1-02
Compiler Used: Microsoft Visual C++ 2010 Express // A-1-1-02
SourceFile Name: Payroll.cpp // A-1-1-02
*/ // A-1-1-03
#include <iostream> // A-1-1-04
#include <iomanip> // A-1-1-05 TODO
#include <string> // A-1-1-06
#include <stdio.h>
using namespace std; // A-1-1-07
class Payroll { // A-1-1-08
public: // A-1-1-09
void calculateCurrentPayroll() { // A-1-1-10
const double c_maximumHoursWorkedWithoutOvertimePay = 40; // A-1-3-01 TODO
const static int c_inputPromptWidth = 17; // A-1-3-02 TODO
double grossPay; // A-1-3-03
double hoursWorked; // A-1-3-04 TODO
double hourlyPayRate; // A-1-3-05 TODO
const double c_overtimePayRatePremium = 1.5; // A-1-3-06 TODO
int employeeNumber = 1; // A-1-3-07
while (employeeNumber <= getEmployeeCount()) { // A-1-3-08
cout << "\n\tEnter employee", employeeNumber; // A-1-3-09 TODO
cout << "\n\t\tHours Worked"; // A-1-3-10 TODO
cin >> hoursWorked; // A-1-3-11 TODO
cout << "\n\t\tHourly Pay Rate"; // A-1-3-12 TODO
cin >> hourlyPayRate; // A-1-3-13 TODO
if (hoursWorked <= 40) // A-1-3-14 TODO
grossPay = hoursWorked * hourlyPayRate; // A-1-3-15 TODO
else // A-1-3-16 TODO
grossPay = c_maximumHoursWorkedWithoutOvertimePay * hourlyPayRate // A-1-3-17 TODO
+ hoursWorked - c_maximumHoursWorkedWithoutOvertimePay // A-1-3-18 TODO
* hourlyPayRate * c_overtimePayRatePremium; // A-1-3-19 TODO
// // A-1-3-20 TODO
employeeGrossPay[employeeNumber - 1] = grossPay; // A-1-3-21
employeeNumber++; // A-1-3-22
}// while // A-1-3-23
} // function calculateCurrentPayroll // A-1-1-11
void displayCurrentPayroll() { // A-1-1-12
int employeeNumber = 1; // A-1-3-24 TODO
employeeNumber <= getEmployeeCount(); // A-1-3-25 TODO
cout << "\n\temployee number" // A-1-3-26 TODO
"\t" << fixed << showpoint << setprecision(2); // A-1-3-27 TODO
cout << employeeGrossPay[employeeNumber - 1]; // A-1-3-28 TODO
employeeNumber++; // A-1-3-29 TODO
} // A-1-3-30 TODO
// function displayCurrentPayroll // A-1-1-13
int getEmployeeCount() { // A-1-1-14
return c_employeeCount; // A-1-3-31
} // function getEmployeeCount // A-1-1-15
private: // A-1-1-16
const static int c_employeeCount = 3; // A-1-1-17
double employeeGrossPay[c_employeeCount]; // A-1-1-18
}; // class Payroll // A-1-1-19
int main() { // A-1-5-01
Payroll currentPayroll; // A-1-5-02 TODO
string enterKey; // A-1-5-03
cout << "\nTask 06-02, Ch04, Programmed by Shawn Main"; // A-1-5-04
cout << "\n\nProgram Input:"; // A-1-5-05
currentPayroll.calculateCurrentPayroll(); // A-1-5-06 TODO
cout << "\nProgram Output:"; // A-1-5-07 TODO
cout << "\n\t # Gross Pay"; // A-1-5-08 TODO
currentPayroll.displayCurrentPayroll(); // A-1-5-09 TODO
rewind( stdin ); // A-1-5-10 TODO
cout << "\n\nEnd of program: Press <Enter> key to exit program."; // A-1-5-11
getline(cin, enterKey); // A-1-5-12
} // function main // A-1-5-13
Copyright © 2024, NextGenUpdate.
All Rights Reserved.