this question using C++, please 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 weighs 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 and including the maximum load.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

this question using C++, please

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 weighs 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 and including 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 four 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.

 

Output results.

Option ‘a’: Get an integer representing the weight of the item in pounds. Attempting to add items to the load which are not between 50 pounds and 1000 pounds will bring up an item rejection message and go back to the menu (i.e., do not try to make another input loop in order to force the user to type in a valid value). The user also will get a rejection message if a valid weighted item would put the load over 2000 pounds – in this case the program needs to NOT add the weight to the load, NOT increase the item count, and go back to the menu. Points will be marked down if the number of items loaded is incremented during these error conditions. For valid weights add the item to the load, increment the number of items loaded, and 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.

/*CS 161 Assignment 4

  Filename: a04.cpp

  Author:   ___

  Date:     ___

  Summary:  (describe the program’s purpose, and then describe how the input is transformed into the output)

 

Variables (data type, name, purpose):

    ___

 

Equations (include logic equations!):

    ___

*/

Expert Solution
Step 1

Computer Science homework question answer, step 1, image 1

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Algebraic Expressions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education