Answer to Question #32370 in C++ for amal
• Execution 1: Input the weight as a negative number of ounces.
• Execution 2: Input the weight as 0ounces.
• Execution 3: Input the weight as 5 ounces.
• Execution 4: Input the weight as 42 ounces.
Write three independent functions for this program assignment as follows:
• One function to read the required input values.
• A second function to perform the required calculations using the input values from the first function.
• A third function to display the results of the second function.
Speedy-Pants Delivery Inc. charges by weight for delivery of packages. The delivery charge for the first pound is $3.00 and $0.50 is added onto the charge for each additional four ounces.
A package weighing more than 16 but at most 20 ounces costs $3.50 to deliver.
A package weighing more than 20 but at most 24 ounces costs $4.00 to deliver. etc.
Write a program that inputs the weight of a package in ounces, computes the charge for delivery, and displays it to the screen. NOTE: One pound equals 16 ounces.
(1) Use a double-valued function, weight_input, to prompt the user for input.
(2) Use a double-valued function, compute_delivery_charge, to compute the charge for delivery.
(3) Use a void function, display_delivery_charge, to display the delivery charge.
using namespace std;
cout << "Input the weight in ounces: ";
cin >> i;
while (i <= 0)
cout << "Please, input a positive value of the weight. It can not be less or equal than zero."<< endl;
cin >> i;
double computeDeliveryCharge(double weight)
double c = 3.0;
if (weight <= 16) return c;
weight -= 16;
weight /= 4;
int n = ceil(weight);
c += n * 0.5;
void displayDeliveryCharge (double charge)
cout << "Charge: " << charge << endl;
double x = weightInput();
double y = computeDeliveryCharge(x);
cout << "
Need a fast expert's response?Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!