Lab 04: Control Statements and Jumps-2024.10.15
1. Write a program that requests the hours worked in a week and then prints the gross
pay, the taxes, and the net pay. Assume the following:
a. Basic pay rate = $10.00/hr
b. Overtime (in excess of 40 hours) = time and a half
c. Tax rate: #15% of the first $300, 20% of the next $150, 25% of the rest
Use #define constants, and don’t worry if the example does not conform to current
tax law.
2. Modify assumption a. in exercise 1 so that the program presents a menu of pay rates
from which to choose. Use a switch to select the pay rate. The beginning of a run should
look something like this:
Enter the number corresponding to the desired pay rate or action:
1) $8.75/hr 2) $9.33/hr 3) $10.00/hr 4) $11.20/hr 5) quit
The program should request the hours worked if choices 1 through 4 are selected. The
program should recycle until 5 is entered. If something other than choices 1 through 5
is entered, the program should remind the user what the proper options are and then
recycle. Use #define constants for the various earning rates and tax rates.
3. Write a program that accepts a positive integer as input and then displays all the
prime numbers smaller than or equal to that number.
4. The ABC Mail Order Grocery sells artichokes for $2.05 per pound, beets for $1.15
per pound, and carrots for $1.09 per pound. It gives a 5% discount for orders of $100
or more before adding shipping costs. It charges $6.50 shipping and handling for any
order of 5 pounds or under, $14.00 shipping and handling for orders over 5 pounds and
under 20 pounds, and $14.00 plus $0.50 per pound for shipments of 20 pounds or more.
Write a program that uses a switch statement in a loop such that a response of a lets the
user enter the pounds of artichokes desired, b the pounds of beets, c the pounds of
carrots, and q allows the user to exit the ordering process. The program should keep
track of cumulative totals. That is, if the user enters 4 pounds of beets and later enters
5 pounds of beets, the program should report 9 pounds of beets. The program then
should compute the total charges, the discount, if any, the shipping charges, and the
total. The program then should display all the purchase information: the cost per pound,
the pounds ordered, and the cost for that order for each vegetable, the total cost of the
order, the discount (if there is one), the shipping charge, and the total of all the charges.
Submission Requirements: Use a folder to include all source files for each question.
For example, this lab contains three questions, so you need to create three folders, each
of which needs to save source files for each question. Then, you need to submit the
compressed file containing these folders to the Moodle platform.
版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。