Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. // Example program
  2. #include <iostream>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8. const double COST_PER_CUBIC_FOOT = 0.23;
  9. const double CHARGE_PER_CUBIC_FOOT = 0.5;
  10.  
  11. //Variables
  12. double length, //The Crate's length
  13. width, // THe Crate's Width
  14. height, //The Crate's height
  15. volume, //THe volume of the crate
  16. cost, // The cost to build teh crate
  17. charge, // the customer charge
  18. profit, // the profit made on crate;
  19.  
  20. // Set desired output
  21. cout << setprecision(2) << fixed << showpoint;
  22. //Prompt the uder for the crate's length, width, and height
  23. cout << "Enter the dimensions of the crate (in feet): \n";
  24. cout << "Length: 10 ";
  25. cin >> length;
  26. cout << "Width: 8 ";
  27. cin >> width;
  28. cout << "Height: 4 ";
  29. cin >> height;
  30.  
  31. //calculate crate's volume
  32. //charge of customer and profit
  33. volume = length * width * height;
  34. cost = volume * COST_PER_CUBIC_FOOT;
  35. charge = volume * CHARGE_PER_CUBIC_FOOT;
  36. profit = charge - cost;
  37.  
  38. //display data
  39. cout << "The vloume of the crate is ";
  40. cout << volume << " cubic feet.\n";
  41. cout << "Cost to build: $" << cost << endl;
  42. cout << "Charge to customer: $" << charge << endl;
  43. cout << "Profit: $" << profit << endl;
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement