Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Show how to create a mobile/computer app using the c++ code below #include // required header files #include #include using namespace std; int main() //

Show how to create a mobile/computer app using the c++ code below

#include // required header files #include #include

using namespace std;

int main() // driver method { cout << "This program calculates the net pay for the each employee and the gross pay." << endl; // prompt about the code cout << " At each prompt, enter the requested data." << endl; double payRate, workedHrs, regPay, otPay, grossPay, tx, netPay, totGrossPay = 0, totNetPay = 0, totTax = 0, totalPay = 0; // local varaibles int empCount = 0; char empCode, stateCode, choice; while(true) { // iterate till the user desire to exit empCount++; // count of the employess gets incremented cout << " Enter the pay rate : "; // prompt to enter the pay rate cin >> payRate; // get the pay rate cout << "Enter the number of hours worked : "; // prompt to enter the hours cin >> workedHrs; // get the data cout << "Enter the Employee Code (A or B) : "; // prompt to enter the emp code cin >> empCode; // get the data cout << "Enter the state code (Y or J) : "; // prompt to enter the state code cin >> stateCode; // get the data if(workedHrs <= 40) { // check for the worked hours regPay = payRate * workedHrs; // calculate the amount otPay = 0; } else { regPay = payRate * 40; payRate = payRate * 1.5; otPay = payRate * (workedHrs - 40); // calculate the Overtime } cout.precision(2); // set the precision of the console to 2 digits cout << " Regular Pay : " << setw(8) << fixed << regPay << endl; // print the data cout << "Overtime Pay : " << setw(7) << fixed << otPay << endl; // print the data grossPay = regPay + otPay; // calculate the gross pay cout << "Gross Pay : " << setw(10) << fixed << grossPay << endl; // print the data totalPay = regPay + otPay; // calculate the total pay totGrossPay = totGrossPay + grossPay; // calculate the total gross pay if(empCode == 'A') { // claculate the tax payable if(stateCode == 'Y') { tx = totalPay * 0.07; } else if (stateCode == 'J') { tx = totalPay * 0.045; } } else if(empCode == 'B') { tx = 0; } cout << "Tax : " << setw(16) << fixed << tx << endl; // print the data totTax = totTax + tx; cout << "--------------------------------" << endl; netPay = grossPay - tx; // calculate the net pay totNetPay = totNetPay + netPay; cout << "Net Pay : " << setw(11) << fixed << netPay << endl; // print the data cout << " Do you want to process another employee (y or n) : "; // get the choice for the next user to enter cin >> choice; // get the data if(choice == 'n') { // check for the choice break; } else { continue; } } cout << " Total Number of Employees Processed : " << empCount << endl; // print the resultant data cout << "Total Gross Pay : " << setw(8) << fixed << totGrossPay << endl; cout << "Total Tax : " << setw(14) << fixed << totTax << endl; cout << "Total Net Pay : " << setw(10) << fixed << totNetPay << endl; return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions