C
C
The store's employees are paid by the hour. The program should prompt the user to enter
for each employee the number of hours worked for the week and the hourly pay rate. The
program is to calculate each employee's gross pay, including the possibility of overtime pay.
Regular pay is the number of hours the employee worked (up to 40 hours) times the hourly
pay rate. The program is to pay overtime if the employee worked more than 40 hours. The
overtime pay equals the number of hours the employee worked over 40 hours, multiplied
by 1.5 (the overtime pay factor), multiplied by the hourly pay rate. The program should
output the worker's regular pay, overtime pay, and gross pay (the sum of the regular pay
and overtime pay). Then the program should ask the user if he/she wants to process
another employee. If there is another employee to process, the program should calculate
the pay as described earlier. When the user responds that there are no more employees to
process, the program should display the number of employees it processed and the total
payroll, that is, the sum of the gross salaries of the employees.
2. The following problem uses a nested if to calculate the tax on employee pay and discusses
how to input single characters in response to program prompts.
An automobile repair shop wants you to write a payroll program for its employees. The
program must calculate each employee's net salary, that is, the salary after taxes. Prompt
the user for the employee's pay rate, hours worked, employee code (either 'A' for full time
or 'B' for part-time), and state code (either 'Y' for New York or 'J' for New Jersey). Allow the
user to enter either uppercase or lowercase letters. The program should display the regular
pay, the overtime pay, the gross pay, the tax, and the net pay.
Calculate the gross pay as follows. If the employee worked 40 hours or less, the regular pay
is the pay rate times the hours worked and overtime pay is zero. If the employee worked
over 40 hours, the regular pay is the pay rate times 40 and the overtime pay is 1.5 times the
pay rate times the hours worked over 40.
Calculate the tax as follows. If the employee code is 'A' and the state code is 'Y', the tax is
7% of the gross pay. If the employee code is 'A' and the state code is not 'Y', the tax is 4.5%
of the gross pay. If the employee code is not 'A', the tax is zero. The net pay is the gross pay
minus the tax.
After the program processes the last employee, it should display the total number of
employees it processed and the total gross pay, tax, and net pay.
3. Suppose that the automobile repair shop of Problem 4.2 has a maximum pay rate of $25.00.
Recode prb04-2.cpp so that it issues an error message if the user enters a pay rate greater
than 25.00. The program should prompt the user for a valid pay rate until the user enters a
rate of $25.00 or less.
4. The loan officer at Humongus National Bank wants you to write a program to help her
decide whether to approve small loan applications. The program should prompt the user for
the customer's yearly income, the number of years of the loan (the loan period), the
amount of the loan (the principal), and the customer status (1 for preferred, or 0 for
ordinary). To approve a loan, the customer must satisfy one of the following conditions.
a. The principal divided by the period must be less than or equal to 1/12 of the customer's
income.
b. If the customer is a preferred customer (that is, the customer status is 1), the principal
divided by the period need only be less than or equal to 1/10 of the customer's income.
The program should display an appropriate approval or disapproval message for each customer
it processes. When there are no more customers to process, the program should display the
total number of approvals and disapprovals it processed.
5. At Humongus National Bank, the vice president in charge of credit cards decides to issue a
new type of credit card, the Platinum Card. Write a program to help the bank decide which
of its customers it will offer a Platinum Card. The program should prompt the user for the
customer's present credit limit and account balance. If a customer has a credit limit of at
least $2000.00 and an account balance of $500.00 or less, issue the customer a Platinum
card. If a customer has a credit limit of at least $2000.00 and an account balance of more
than $500.00, send a letter to the customer stating that if their balance falls below $500.00
he or she will receive a Platinum Card. If a customer does not fall into either of these
categories, take no action.
For each customer, the program should display a message that shows the action that the
bank should takeissue a Platinum Card, send a letter, or no action. When there are no more
customers to process, the program should display the total number of customers in each
category.
6. The Big Racket Tennis Club wants you to write a program to calculate the yearly dues for its
members. The program should prompt the user for the membership type (either 'I' for
individual, or 'F' for family) and the number of years the person has been a member.
Calculate the dues as follows: If the person is a family member and has been a club member
for more than three years, the dues are $2400.00. If the person is a family member and has
been a club member for three years or less, the dues are $3000.00. If the person is an
individual member and has been a club member for more than five years, the dues are
$1500.00. If the person is an individual member and has been a club member for five years
or less, the dues are $1900.00.
7. Write a program for The Department of Motor Vehicles (DMV) to calculate the registration
fees for automobiles. The DMV classifies automobiles as type 1, for luxury, or as type 2, for
all others. The registration fee for an automobile is $35.00. If the automobile is a luxury
vehicle, add a surcharge of $15.00. The DMV also classifies automobiles as city vehicles
(class 1) or non-city vehicles (class 2). An automobile that is registered in the city of
Metropolis must pay an additional surcharge of $20.00, no matter what its type. Your
program should prompt the user for the luxury type (either 1 or 2) and for the city class
(either 1 or 2) of the automobile. The program should display the total registration fee for
the vehicle. Design the program to process any number of automobiles.
8. Write a program for a mail-order software company to calculate shipping and handling
charges for its orders. The program should prompt the user for the weight of the order in
ounces. If the weight is eight ounces or less, then there is a flat rate charge of $1.50. If the
weight of the order is more than eight ounces but less than 32 ounces, the charge is $1.50
plus $0.50 for each ounce over eight. If the weight of the order is 32 ounces or greater, the
charge is $13.50 plus $0.75 for each ounce over 32. The program should display the weight
of the order and the shipping and handling charge. Design the program to process any
number of orders. At the end of the program, display the total number of orders processed
and the total of the shipping and handling charges.
9. A bank's vice president in charge of small loans needs a program to help her approve or
disapprove loans. Write a program that meets the following requirements. The program
should prompt the user for the annual income of the loan applicant, the amount of the
loan, and the number of years of the loan. The program should display an approval or
rejection message, as appropriate. Approve the loan in either of the following cases: if the
amount of the loan is less than $5,000.00 and the applicant's annual income is at least
$30,000.00; or if the amount of the loan is greater than or equal to $5,000.00 and less than
$20,000.00, and the applicant's annual income is at least $75,000.00. In all other cases,
reject the application.
10. A swimming pool maintenance company wants you to write a program to estimate the cost
of resurfacing the inside of in-ground pools. The program is to process an indeterminate
number of estimates. To make an estimate, the program should ask the user to input the
length, width, and depth of the pool, each to the nearest tenth of a foot. The company
charges $2.25 per square foot. The following formula gives the inside surface area of a pool.
Include a sales tax of 7.75% in the estimate. The program should display the dimensions of
the pool and the estimated cost to the nearest penny for each customer it processes. Write
the required program.
11. A cattle-feed company needs a program to help process feed orders. The program is to
process an indeterminate number of orders. Each customer orders one or both of two types
of feed, A and B. Feed A costs $2.50 per 100 pounds and feed B costs $3.15 per 100 pounds.
Amounts less than 100 pounds are to be charged proportionally. For each customer, the
program should ask the user to enter the actual number of pounds ordered for each of
feeds A and B to the nearest tenth of a pound. The program should display the amount and
cost of each type of feed and the total cost of the order. When no more customers are to be
processed, the program should display the total number of customers processed, the total
amount of feed A ordered, and the total amount of feed B ordered to the nearest tenth of a
pound, and the total receipts. Write the required program.
12. A computer science instructor needs a program that averages the grades she receives on a
quiz she gives to her class. Each grade is an integer between 0 and 100. She does not know
the number of grades at this time. Write a program that asks the user to enter quiz grades
one at a time. After the user has completed entering grades, the program should display the
number of grades entered and the sum of the grades entered. The program should also
display the average of the grades, rounded to the nearest tenth.
13. A computer science instructor wants you to write a program to compute final grades for her
Introduction to Computers course. The program is to process an indeterminate number of
students. For each student the program should ask the user to enter the mid-term and final
exam scores and then display the student's final grade. The final grade is the sum of 45% of
the mid-term exam score and 55% of the final exam score. After it processes all the
students, the program should display the number of students it processed, and the average
mid-term exam score, average final exam score, and average final grade all to the nearest
tenth. Write the required program.
14. A bank wants you to write a program to calculate the amounts in accounts that earn simple
interest. The program should process an indeterminate number of accounts. The following
formula gives the amount in an account, in which the principal is the initial investment.
The following formula gives the interest, in which the rate is the annual interest rate as a
decimal and time is the number of years the principal is at interest.
For each account, the program should ask the user to input the principal, the interest rate to
the nearest tenth as a percent (for example, 7.7), and the number of years at interest. The
program should then display the principal, the interest, and the amount in the account after the
given number of years. When there are no more customers to process, the program should
display the number of accounts processed and the total principal and total interest paid. Write
the required program.