Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main ()
- {
- const double COST_PER_CUBIC_FOOT = 0.23;
- const double CHARGE_PER_CUBIC_FOOT = 0.5;
- //Variables
- double length, //The Crate's length
- width, // THe Crate's Width
- height, //The Crate's height
- volume, //THe volume of the crate
- cost, // The cost to build teh crate
- charge, // the customer charge
- profit, // the profit made on crate;
- // Set desired output
- cout << setprecision(2) << fixed << showpoint;
- //Prompt the uder for the crate's length, width, and height
- cout << "Enter the dimensions of the crate (in feet): \n";
- cout << "Length: 10 ";
- cin >> length;
- cout << "Width: 8 ";
- cin >> width;
- cout << "Height: 4 ";
- cin >> height;
- //calculate crate's volume
- //charge of customer and profit
- volume = length * width * height;
- cost = volume * COST_PER_CUBIC_FOOT;
- charge = volume * CHARGE_PER_CUBIC_FOOT;
- profit = charge - cost;
- //display data
- cout << "The vloume of the crate is ";
- cout << volume << " cubic feet.\n";
- cout << "Cost to build: $" << cost << endl;
- cout << "Charge to customer: $" << charge << endl;
- cout << "Profit: $" << profit << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement