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

In Chapter 2, you designed a program for Cost Is No Object—a car rental service

ID: 3624127 • Letter: I

Question

In Chapter 2, you designed a program for Cost Is No Object—a car rental service that specializes in lending antique and luxury cars to clients on a short-term basis. Complete the decision structure pseudocode for the following;

1. If the contract number is not between 10000 and 99999 inclusive, issue an error message and end the program.
2. The insurance indicator must be “Y” or “N” (for “Yes” or “No”); otherwise, display an error message and assume “Y”.
3. If all the entered data is valid, display it along with the fee for the rental, which is calculated as follows:
1. $25 per day for 10 days or fewer
2. $18 per day for each day over 10 days
3. $2.50 per day for insurance, regardless of the number of days in the contract



Looping
Case: Cost Is No Object
1. 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.

Create looping structure pseudocode 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:

1. An employee ID must be between 100 and 999 inclusive.
2. A zip code must not be greater than 99999.
3. An hourly pay rate must be between $6.00 and $25.00 inclusive.
4. The number of hours worked in a week cannot be negative or more than 70.
5. An insurance plan code must be 1 or 2.

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)