Question: In C++ Language: In this assignment you will practice using the switch statement inside of a while loop. The program you need to write is

In C++ Language:

In this assignment you will practice using the switch statement inside of a while loop. The program you need to write is an interactive calculator for loading a light-duty electric truck. This truck moves equipment between warehouses, with each item restricted to 50 pounds to 1000 pounds. If the user attempts to add items to the load which weigh outside this range, write code to bring up an item rejection message and do not add that item to load. The maximum load that the truck can safely carry weighs 2000 pounds, so you will need to write code that enforces the limit. To ensure that your algorithm and implementation worked correctly, test the program and make sure that works up to the maximum load.

Program requirements:

Use the switch statement inside of a while loop, as well as any other control structures such as if-else.

Prompt for a command.

There are three valid commands, a, r, i, and e which are iteratively displayed. The output prompt should look like a menu:

Truck load calculator menu

( a ) Add an item to the load.

( r ) Display remaining load capacity.

( i ) Display number of items loaded.

( e ) Exit program.

Attempting to add items to the load which are not between 50 pounds and 1000 pounds will bring up an item rejection message. In this case the variable representing number of items loaded should not be incremented.

Output results.

Option a: Get an integer representing the weight of the item in pounds. If adding the item would put the load over 2000 pounds then display a rejection message, otherwise add the item to the load and increment the number of items loaded. In either case, display the resulting current weight of the load in pounds.

Option r: Display the remaining load capacity in pounds followed by the units (e.g., 270 pounds ).

Option i: Display the number of items loaded.

Option e: Exit the program.

All other input: Display a friendly message indicating that the selected input command was invalid.

Program template:

Copy the code below and fill in the blanks. If you like extend these comments listing all variables in the program.

Date: ___

Summary: (describe the programs purpose, then describe how the input is transformed into the output)

Variables (data type, name, purpose):

___

Equations (if any):

___

*/

Design Considerations:

  1. No global variables. All variables must be inside main().
  2. Above main() write code comments describing the assignment.
  3. Your application must be data driven meaning your answer should be built from user input.
  4. Points will be awarded for the following attributes of your solution.
  1. If your program does not compile you will get at most 30% of the maximum points irrespective of what the error is.
  2. If your program compiles, then points are awarded for correctness, readability, and documentation. Your source code needs to have good form. In particular, pay attention to your indentation, capitalization, and so forth. Be sure to read the class C++ style guide before working on this problem. However, if you follow the style used in the book you will be fine. Having good documentation requires that you have comments delineating your name, the date, assignment name/number, the assignment description (see above), and outside people or Internet sources that helped you complete this assignment.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!