Question

intructions: please don't use struture and pointers Write a program that displays a weekly payroll report....

intructions: please don't use struture and pointers



Write a program that displays a weekly payroll report. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when 0 is entered for the employee number. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay.

Input Validation: Do not accept negative numbers for any of the items entered. Do not accept values for state, federal, or FICA withholdings that are greater than the gross pay. If the sum of state tax + federal tax + FICA withholdings for any employee is greater than gross pay, print an error message and ask the user to reenter the data for that employee.

Homework Answers

Answer #1

C++ code for Weekly payroll report:

#include<iostream>
using namespace std;

int main()
{      // variables to store totals of amounts
       int total_gross_pay=0;
       int total_state_tax=0;
       int total_federal_tax=0;
       int total_FICA_withholdings=0;
       
       while(1)
       {   
           //variabls to store employee details
   
           int employee_number;
               int gross_pay;
               int state_tax;
               int federal_tax;
               int FICA_withholdings; 
               
               cout<<"enter employee number : ";
               cin>>employee_number;
           
           // break the loop if employee number is 0
               if(employee_number==0)
               break;
     
     // input for gross pay

         label_1:      cout<<"enter gross pay : ";
                       cin>>gross_pay;
               if(gross_pay<0)
                       {
                               cout<<"invalid gross pay!! re-enter!!"<<endl<<endl;

                   // goto label_1 if constrains are not followed
                           goto label_1;
                       }

      // input for state tax
          label_2:     cout<<"enter state tax : ";
                       cin>>state_tax;
                if(state_tax<0 || state_tax > gross_pay)
                       {
                               cout<<"invalid state tax!! re-enter!!"<<endl<<endl;
                               goto label_2;
                       }

      // input for federal tax

      label_3:     cout<<"enter federal tax: ";
                       cin>>federal_tax;
               if(federal_tax<0 || federal_tax > gross_pay)
                       {
                               cout<<"invalid federal tax!! re-enter!!"<<endl<<endl;
                               goto label_3;
                       }
        
      // input for FICA withholdings
       
          label_4:     cout<<"enter FICA withholdings : ";
                       cin>>FICA_withholdings;
                if(FICA_withholdings<0 || FICA_withholdings > gross_pay)
                       {
                               cout<<"invalid FICA withholdings!! re-enter!!"<<endl<<endl;
                               goto label_4;
                       }     
        
          // check if gross pay is sufficient
              if( gross_pay < federal_tax + state_tax + FICA_withholdings )
              {
                    cout<< "gross pay is nsufficient!! re-enter the details !!"<<endl<<endl;
                    goto label_1;
              }

                       total_gross_pay+= gross_pay;
                       total_federal_tax+= federal_tax;                                
                   total_state_tax += state_tax;
                       total_FICA_withholdings+= FICA_withholdings;

                       cout<<endl<<endl;

       }//end of while loop 

        cout<<"----------------------------------------------"<<endl<<endl;
        cout<<"Total gross pay : "<<total_gross_pay<<endl;
            cout<<"Total federal tax : "<<total_federal_tax<<endl;
            cout<<"Total state tax : "<<total_state_tax<<endl;
        cout<<"Total FICA withholdings : "<<total_FICA_withholdings<<endl;



        return 0;
}

Test run output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a PYTHON program that displays a weekly payroll report. A loop in the program should...
Write a PYTHON program that displays a weekly payroll report. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when 0 is entered for the employee number. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay. Input Validation: ▪ Do not accept negative numbers for any of the items entered....
In C programming language please. -Construct a program that will make use of user defined functions,...
In C programming language please. -Construct a program that will make use of user defined functions, the do/while loop, the for loop and selection. -Using a do/while loop, your program will ask/prompt the user to enter in a positive value representing the number of values they wish to have processed by the program or a value to quit/exit. -If the user enters in a 0 or negative number the program should exit with a message to the user indicating they...
The following summary data for the payroll period ended December 27, 2015, are available for Cayman...
The following summary data for the payroll period ended December 27, 2015, are available for Cayman Coating Co.:      Gross pay $ 95,000 FICA tax withholdings ? Income tax withholdings 14,710 Group hospitalization insurance 1,930 Employee contributions to pension plan ? Total deductions 27,177 Net pay ? Additional information: For employees, FICA tax rates for 2015 were 7.65% on the first $118,500 of each employee’s annual earnings. However, no employees had accumulated earnings for the year in excess of the $118,500...
Write a program in C++ coding that asks the user to input an integer between 25...
Write a program in C++ coding that asks the user to input an integer between 25 and 50, inclusive. Utilize a WHILE loop to test for INVALID input. If the input is INVALID, the loop will repeat, and ask the user to try again. The pseudocode looks like this: Prompt user to input an integer between 25 and 50 Accept the input from the user Test for invalid input (HINT: use a while loop and the OR operator with 2...
Write a program that asks the user to input an integer between 25 and 50, inclusive....
Write a program that asks the user to input an integer between 25 and 50, inclusive. Utilize a WHILE loop to test for INVALID input. If the input is INVALID, the loop will repeat, and ask the user to try again. The pseudocode looks like this: Prompt user to input an integer between 25 and 50 Accept the input from the user Test for invalid input (HINT: use a while loop and the OR operator with 2 relational expressions. You...
(Use C++ language) Create a program, named threeTypesLoops.cpp, that does the following; 1. Uses a For...
(Use C++ language) Create a program, named threeTypesLoops.cpp, that does the following; 1. Uses a For Loop that asks for a number between 1 and 10; Will double the number each time through the loop and display the answer. Will run five times, so the number will have been doubled five times, and the answer displayed five times. After the loop, display a message saying 'It's done!'. 2. Uses a While Loop; Ask the user to input a friend's name....
Write a program which: Write a program which uses the following arrays: empID: An array of...
Write a program which: Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to hold each employee’s gross salary....
NO EXPLANATION REQUIRED. CHOOSE THE WRITE OPTION. QUE5. The amount an employee earns before any deductions...
NO EXPLANATION REQUIRED. CHOOSE THE WRITE OPTION. QUE5. The amount an employee earns before any deductions such as EI, CPP, and income tax withholdings is the A- Taxable income B- Gross pay C- Take home pay D- Deductible pay E- Net pay QUE6. A tax levied on the amount of a payroll or on the amount of an employee's gross pay is a(n) A- Excess profits tax B- Federal program C- Employer tax D- Employee tax E- Payroll tax QUE7....
Check My WorkCheck My Work BUSINESS DECISION: TAKE HOME PAY You are the payroll manager for...
Check My WorkCheck My Work BUSINESS DECISION: TAKE HOME PAY You are the payroll manager for the Canyon Ridge Resort. Bob Farley, the marketing director, earns a salary of $42,000 per year, payable monthly. He is Married and claims three withholding allowances. His social security number is 462-12-8749. In addition to federal income tax, social security, and Medicare, Bob pays 2.3% state income tax, % for state disability insurance (both based on gross earnings), $26.15 for term life insurance, $123.74...
Write a program display the following menu: Ohms Law Calculator 1. Calculate Resistance in Ohms 2....
Write a program display the following menu: Ohms Law Calculator 1. Calculate Resistance in Ohms 2. Calculate Current in Amps 3. Calculate Voltage in volts 4. Quit Enter your choice (1-4) If the user enters 1, the program should ask for voltage in Volts and the current in Amps. Use the following formula: R= E/i Where: E= voltage in volts I= current in amps R= resistance in ohms If the user enters 2 the program should ask for the voltage...