Control Statements and Jumps

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 grosspay, the taxes, and the net pay. Assume the following:
  1. Basic pay rate = $10.00/hr
  2. Overtime (in excess of 40 hours) = time and a half
  3. Tax rate: #15% of the first $300, 20% of the next $150, 25% of the restUse #define constants, and don’t worry if the example does not conform to currenttax law.
  1. Modify assumption a. in exercise 1 so that the program presents a menu of pay ratesfrom which to choose. Use a switch to select the pay rate. The beginning of a run shouldlook something like this:

*********************************************************************

Enter the number corresponding to the desired pay rate or action:

  1. 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 5is entered, the program should remind the user what the proper options are and thenrecycle. Use #define constants for the various earning rates and tax rates.

  1. Write a program that accepts a positive integer as input and then displays all theprime numbers smaller than or equal to that number.
  1. The ABC Mail Order Grocery sells artichokes for 代 写Control Statements and Jumps  $2.05 per pound, beets for $1.15per pound, and carrots for $1.09 per pound. It gives a 5% discount for orders of $100or more before adding shipping costs. It charges $6.50 shipping and handling for anyrder of 5 pounds or under, $14.00 shipping and handling for orders over 5 pounds andunder 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 theuser enter the pounds of artichokes desired, b the pounds of beets, c the pounds ofcarrots, and q allows the user to exit the ordering process. The program should keeptrack of cumulative totals. That is, if the user enters 4 pounds of beets and later enters5 pounds of beets, the program should report 9 pounds of beets. The program thenshould compute the total charges, the discount, if any, the shipping charges, and thetotal. 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 theorder, 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, eachof which needs to save source files for each question. Then, you need to submit thecompressed file containing these folders to the Moodle platform.

posted @ 2024-10-22 18:59  hellyou  阅读(2)  评论(0编辑  收藏  举报