Assume you're writing this menu-driven program for a shipping company. There are two types of shipments: normal and expedited. a. As shown in Program 4-18, please declare constants for the types of shipments. Please write the names of constants in ALL CAPS. b. Show the menu in a clear form, and prompt the user for the type of shipment; the rest of the program depends on the type of shipment chosen. c. 1. For normal shipments, ask for the weight of the package (double) and the distance (int). Then use the table on the right: Rate per 100 miles 2.03 Weight 1 Ib. or less more than 1 lb., less than 4 Ib. at least 4 Ib., less than 10 Ib. 10 lb. or more The smallest distance offered is 15 miles, and the greatest is 900 miles 3.95 6.57 8.26 2. For expedited shipments, ask for the weight of the package (double) and the distance (int). Then use the table on the right: Weight 1 lb. or less more than 1 lb., less than 4 Ib. at least 4 Ib., less than 10 Ib. 10 lb. or more Rate per 100 miles 3.10 The smallest distance offered is 10 miles, and the greatest is 500 miles 4.28 7.13 9.75 3. Please verify the user input each time the user enters a value. If the input is incorrect, set a flag to indicate that condition. You'll need the flag when you display output. d. Output. Here are some scenarios. Ex1: The shipment type is normal, the weight is 6.3 pounds, and the distance is 700 miles. The output should look like: Shipment type : Normal : 6.300 : 700 : $45.99 Weight Distance Cost Ex2: The shipment type is expedited, the weight is 3.42 pounds, and the distance is 475 miles. The output should look like: Shipment type : Expedited : 3.420 : 475 : $20.33 Weight Distance Cost Ex3: The input is invalid for at least one of the prompts. The only output should be: There was invalid input. Please try again.

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

Please, I need to answer this question using the C++ programming language and Visual Studio. Thank you.

 

Program 4-18 

// This program displays a menu and asks the user to make a

// selection. An if/else if statement determines which item

// the user has chosen.

#include <iostream>

#include <iomanip>

using namespace std;

 

int main()

{

int choice;     // To hold a menu choice

int months;     // To hold the number of months

double charges; // To hold the monthly charges

 

// Constants for membership rates

const double ADULT = 40.0,

             SENIOR = 30.0,

             CHILD = 20.0;

 

// Constants for menu choices

const int ADULT_CHOICE = 1,

          CHILD_CHOICE = 2,

          SENIOR_CHOICE = 3,

          QUIT_CHOICE = 4;

 

// Display the menu and get a choice.

cout << "\t\tHealth Club Membership Menu\n\n"

     << "1. Standard Adult Membership\n"

     << "2. Child Membership\n"

     << "3. Senior Citizen Membership\n"

     << "4. Quit the Program\n\n"

     << "Enter your choice: ";

cin >> choice;

 

// Set the numeric output formatting.

cout << fixed << showpoint << setprecision(2);

 

// Respond to the user's menu selection.

if (choice == ADULT_CHOICE)

{

   cout << "For how many months? ";

   cin >> months;

   charges = months * ADULT;

   cout << "The total charges are $" << charges << endl;

}

else if (choice == CHILD_CHOICE)

{

   cout << "For how many months? ";

   cin >> months;

   charges = months * CHILD;

   cout << "The total charges are $" << charges << endl;

}

else if (choice == SENIOR_CHOICE)

{

    cout << "For how many months? ";

    cin >> months;

    charges = months * SENIOR;

    cout << "The total charges are $" << charges << endl;

}

else if (choice == QUIT_CHOICE)

{

    cout << "Program ending.\n";

}

else

{

    cout << "The valid choices are 1 through 4. Run the\n"

         << "program again and select one of those.\n";

}

return 0;

}

Assume you're writing this menu-driven program for a shipping company.
There are two types of shipments: normal and expedited.
a. As shown in Program 4-18, please declare constants for the types of shipments. Please write the
names of constants in ALL CAPS.
b. Show the menu in a clear form, and prompt the user for the type of shipment; the rest of the program
depends on the type of shipment chosen.
c. 1. For normal shipments, ask for the weight of the package (double) and the distance (int). Then use
the table on the right:
Rate per 100 miles
2.03
Weight
1 Ib. or less
more than 1 lb., less than 4 Ib.
at least 4 Ib., less than 10 Ib.
10 lb. or more
The smallest distance offered is 15 miles,
and the greatest is 900 miles
3.95
6.57
8.26
2. For expedited shipments, ask for the weight of the package (double) and the distance (int). Then
use the table on the right:
Weight
1 lb. or less
more than 1 lb., less than 4 Ib.
at least 4 Ib., less than 10 Ib.
10 lb. or more
Rate per 100 miles
3.10
The smallest distance offered is 10 miles,
and the greatest is 500 miles
4.28
7.13
9.75
3. Please verify the user input each time the user enters a value. If the input is incorrect, set a flag
to indicate that condition. You'll need the flag when you display output.
d. Output. Here are some scenarios.
Ex1:
The shipment type is normal, the weight is 6.3 pounds, and the distance is 700 miles.
The output should look like:
Shipment type : Normal
: 6.300
: 700
: $45.99
Weight
Distance
Cost
Ex2:
The shipment type is expedited, the weight is 3.42 pounds, and the distance is 475 miles.
The output should look like:
Shipment type : Expedited
: 3.420
: 475
: $20.33
Weight
Distance
Cost
Ex3:
The input is invalid for at least one of the prompts. The only output should be:
There was invalid input. Please try again.
Transcribed Image Text:Assume you're writing this menu-driven program for a shipping company. There are two types of shipments: normal and expedited. a. As shown in Program 4-18, please declare constants for the types of shipments. Please write the names of constants in ALL CAPS. b. Show the menu in a clear form, and prompt the user for the type of shipment; the rest of the program depends on the type of shipment chosen. c. 1. For normal shipments, ask for the weight of the package (double) and the distance (int). Then use the table on the right: Rate per 100 miles 2.03 Weight 1 Ib. or less more than 1 lb., less than 4 Ib. at least 4 Ib., less than 10 Ib. 10 lb. or more The smallest distance offered is 15 miles, and the greatest is 900 miles 3.95 6.57 8.26 2. For expedited shipments, ask for the weight of the package (double) and the distance (int). Then use the table on the right: Weight 1 lb. or less more than 1 lb., less than 4 Ib. at least 4 Ib., less than 10 Ib. 10 lb. or more Rate per 100 miles 3.10 The smallest distance offered is 10 miles, and the greatest is 500 miles 4.28 7.13 9.75 3. Please verify the user input each time the user enters a value. If the input is incorrect, set a flag to indicate that condition. You'll need the flag when you display output. d. Output. Here are some scenarios. Ex1: The shipment type is normal, the weight is 6.3 pounds, and the distance is 700 miles. The output should look like: Shipment type : Normal : 6.300 : 700 : $45.99 Weight Distance Cost Ex2: The shipment type is expedited, the weight is 3.42 pounds, and the distance is 475 miles. The output should look like: Shipment type : Expedited : 3.420 : 475 : $20.33 Weight Distance Cost Ex3: The input is invalid for at least one of the prompts. The only output should be: There was invalid input. Please try again.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Introduction to Coding
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
  • SEE MORE 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