23. Write a program to perform the following general steps: Step 1: Ask the user
ID: 671189 • Letter: 2
Question
23. Write a program to perform the following general steps:
Step 1:
Ask the user to enter the dimensions of the crate
Step 2:
Calculate:
the crate’s volume
the cost of building the crate
the customer’s charge
the profit made
Step 3:
Display the data calculated in Step 2.
Ask the user to input the crate's length.
Ask the user to input the crate's width.
Ask the user to input the crate's height.
Calculate the crate's volume.
Calculate the cost of building the crate.
Calculate the customer's charge for the crate.
Calculate the profit made from the crate.
Display the crate's volume.
Display the cost of building the crate.
Display the customer's charge for the crate.
Display the profit made from the crate.
Explanation / Answer
Code:
#include <iostream>
using namespace std;
int main()
{
const double CHARGE_PER_CUBIC_FOOT = 0.5;
double crate_len, crate_width, crate_height;
double crate_vol, creation_cost, cust_charge, total_profit;
cout << " Enter the length of the crate in feet : ";
cin >> crate_len;
cout << " Enter the width of the crate in feet : ";
cin >> crate_width;
cout << " Enter the height of the crate in feet : ";
cin >> crate_height;
crate_vol = crate_len * crate_width * crate_height;
creation_cost = crate_vol * 0.23;
cust_charge = crate_vol * 0.5;
total_profit = cust_charge - creation_cost;
cout << "Volume: " << crate_vol << endl;
cout << "Cost of building crate: $" << creation_cost << endl;
cout << "Customer has to pay: $" << cust_charge << endl;
cout << "Total Profit: $" << total_profit << endl;
return 0;
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.