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

In earlier chapters you developed classes needed for Cost Is No Object—a car ren

ID: 3629164 • Letter: I

Question

In earlier chapters you developed classes needed for Cost Is No Object—a car rental service that specializes in lending antique and luxury cars to clients on a short-term basis. The rental service produces computerized paychecks for its employees every week. Write a program that gets data for each of the following:


An employee ID number


A first name


A last name


A street address


A zip code


An hourly pay rate


Number of hours worked this week


An insurance plan code


Create an application that prompts the user for employee data; the application continues to accept data for new employees until the user enters 0 for an ID number to indicate the desire to quit. While the ID number is not zero, prompt the user for a value for each field in turn. Any time the user enters an invalid value, continue to reprompt the user for the same data. Continue with the next data item only when the previous item is valid, as follows:


An employee ID must be between 100 and 999 inclusive.


A zip code must not be greater than 99999.


An hourly pay rate must be between $6.00 and $25.00 inclusive.


The number of hours worked in a week cannot be negative or more than 70.


An insurance plan code must be 1 or 2.


When all the needed data has been entered correctly for an employee, display a copy of all the data fields for the employee as well as the following:


Gross pay, calculated as hours worked times pay rate


Income tax, which is calculated as 15% of the gross pay if the gross pay is $400 or less; otherwise, it is 20% of the gross pay


Insurance premium, which is $60 for insurance plan code 1 and $100 for insurance plan code 2


Net pay, which is calculated as gross pay minus income tax, minus insurance premium; if the net pay is negative (the employee did not earn enough to cover the tax and insurance), then the net pay should be $0

Explanation / Answer

INPUT contractNumber INPUT insuranceIndicator INPUT days IF contractNumber GREATER THAN OR EQUALS 10000 AND contractNumber LESS THAN OR EQUALS 99999 IF insuranceIndicator EQUALS "N" PRINT "Error: Must have insurance!" insuranceIndicator EQUALS "Y" result EQUALS 0.0 IF days GREATER THAN 10 result EQUALS 18 TIMES days ELSE result EQUALS 25 TIMES days result EQUALS result PLUS (2.50 TIMES days) PRINT "Contract #: " PLUS contractNumber PRINT "Insurance:" PLUS insuranceNumber PRINT "Days: " PLUS days PRINT "Total" PLUS result //Second Case starts here id EQUALS -1 zipCode EQUALS 10000 hourlyPay EQUALS -1 hoursPerWeek EQUALS -1 insurancePlanCode EQUALS -1 DO WHILE (NOT ((id GREATER THAN OR EQUAL 100) AND (id LESS THAN OR EQUAL 999)) OR (id EQUAL 0)) INPUT id IF id IS NOT EQUAL TO 0 WHILE NOT (zipCode IS NOT GREATER THAN 99999) INPUT zipCode WHILE NOT ((hourlyPay GREATER THAN OR EQUAL 6) AND (hourlyPay LESS THAN OR EQUAL 25)) INPUT hourlyPay WHILE NOT ((hoursPerWeek GREATER THAN OR EQUAL 0) AND (LESS THAN OR EQUAL 70)) INPUT hoursPerWeek WHILE NOT (insurancePlanCode EQUALS 1 OR insurancePlanCode EQUALS 2) INPUT insurancePlanCode WHILE (id IS NOT EQUAL TO 0)