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

#include<iostream> using namespace std; int main() { int ch, hours, ex, gsales,

ID: 3822564 • Letter: #

Question

#include<iostream>
using namespace std;
int main()
{
   int ch, hours, ex, gsales, p, weeks;//declaring integer data types
   double hsalary, hpay, cpay, pitem, wsalary, mpay, ppay;//declaring double data types
   int countManager = 0;

   int countHourlyWorker = 0;

   int countCommissionWorker = 0;

   int countPieceWorker = 0;

   do
   {// while loop
       ; cout << "Enter paycode: 1 for Manager , 2 for Hourly worker, 3 for Commission worker, 4 for Piece worker (-1 to end): ";
       cin >> ch //taking user input choice
       switch (ch) { //switch statement with several cases

       case -1:
           cout << "the number of managers is :" << countManager;

           cout << "the number of hourlyworkers is :" << countHourlyWorker;

           cout << "the number of commission workers is :" << countCommissionWorker;

           cout << "the number of pieceworkers is :" << countPieceWorker;

           break;

       case 1://case 1 is about managers pay
           cout << "Manager selected" << endl;
           cout << "Enter the salary per week:";
           cin >> wsalary;
           cout << "Enter no. of weeks worked :";
           cin >> weeks;
           mpay = weeks*wsalary; // formula to calculate managers salary
           cout << "Manger pay is $" << mpay << endl;
           countManager++;
           break;
       case 2://case 2 is about hourly worker salary
           cout << "Hourly worker is selected" << endl;
           cout << "Enter Hourly salary :";
           cin >> hsalary;
           cout << "Enter the total hours worked :";
           cin >> hours;
           if (hours > 40) { //if statement that checks the hours greter than the 40 hrs
               ex = hours - 40;
               hpay = 40 * hsalary; //formula to calculate hourly workers salary for the first 40 hrs
               hpay += (ex*((1.5 / 100)*hours));//add 1.5 times extra for over time workers
               cout << "Hourly worker pay is $" << hpay;
           }
           else {
               hpay = hsalary*hours;
               cout << "Hourly worker pay is $" << hpay << endl;
           }
           countHourlyWorker++;


           break;
       case 3://case 3 is about comission worker pay
           cout << "Commission worker selected" << endl;
           cout << "Enter gross weekly sales:";
           cin >> gsales;
           cpay = ((gsales / 100)*5.7) + 250; //formula to calculate comission workers pay
           cout << "commision workers pay is $" << cpay << endl;
           countCommissionWorker++;


           break;
       case 4:// case 4 is about piece worker pay
           cout << "Piece worker selected";
           cout << "Enter the amount per item :";
           cin >> pitem;
           cout << "Enter the number of items produced :";
           cin >> p;
           ppay = p*pitem; //formula to calculate piece workers salary
           cout << "Piece worker pay is $" << ppay << endl;
           countPieceWorker++;


           break;

       default:
           cout << "You have entered an invalid entry,please try again." << endl;
       }   system("pause");

   } while(ch != -1) //while loop// also ends the program  

  
   system("pause");

   return 0;
}

I am trying to get this at the end when I enter -1.

Enter paycode (-1 to end): -1

the number of managers is:0

the number of hourlyworkers is: 1

the number of commission workers is: 1

the number of pieceworkers is: 0

Explanation / Answer

There were few mistakes in your current program , mainly of semi- colons as wrong places and missing at some.Also to use system we need to include library cstdlib.

#include<iostream>
#include<cstdlib>

using namespace std;
int main()
{
int ch, hours, ex, gsales, p, weeks;//declaring integer data types
double hsalary, hpay, cpay, pitem, wsalary, mpay, ppay;//declaring double data types
int countManager = 0;
int countHourlyWorker = 0;
int countCommissionWorker = 0;
int countPieceWorker = 0;

do
{// while loop
cout << "Enter paycode: 1 for Manager , 2 for Hourly worker, 3 for Commission worker, 4 for Piece worker (-1 to end): ";
cin >> ch; //taking user input choice
switch (ch) { //switch statement with several cases
case -1:
cout << "the number of managers is :" << countManager;
cout << "the number of hourlyworkers is :" << countHourlyWorker;
cout << "the number of commission workers is :" << countCommissionWorker;
cout << "the number of pieceworkers is :" << countPieceWorker;
break;
case 1://case 1 is about managers pay
cout << "Manager selected" << endl;
cout << "Enter the salary per week:";
cin >> wsalary;
cout << "Enter no. of weeks worked :";
cin >> weeks;
mpay = weeks*wsalary; // formula to calculate managers salary
cout << "Manger pay is $" << mpay << endl;
countManager++;
break;
case 2://case 2 is about hourly worker salary
cout << "Hourly worker is selected" << endl;
cout << "Enter Hourly salary :";
cin >> hsalary;
cout << "Enter the total hours worked :";
cin >> hours;
if (hours > 40) { //if statement that checks the hours greter than the 40 hrs
ex = hours - 40;
hpay = 40 * hsalary; //formula to calculate hourly workers salary for the first 40 hrs
hpay += (ex*((1.5 / 100)*hours));//add 1.5 times extra for over time workers
cout << "Hourly worker pay is $" << hpay;
}
else {
hpay = hsalary*hours;
cout << "Hourly worker pay is $" << hpay << endl;
}
countHourlyWorker++;

break;
case 3://case 3 is about comission worker pay
cout << "Commission worker selected" << endl;
cout << "Enter gross weekly sales:";
cin >> gsales;
cpay = ((gsales / 100)*5.7) + 250; //formula to calculate comission workers pay
cout << "commision workers pay is $" << cpay << endl;
countCommissionWorker++;

break;
case 4:// case 4 is about piece worker pay
cout << "Piece worker selected";
cout << "Enter the amount per item :";
cin >> pitem;
cout << "Enter the number of items produced :";
cin >> p;
ppay = p*pitem; //formula to calculate piece workers salary
cout << "Piece worker pay is $" << ppay << endl;
countPieceWorker++;

break;
default:
cout << "You have entered an invalid entry,please try again." << endl;
} system("pause");
} while(ch != -1); //while loop// also ends the program
  
system("pause");
return 0;
}