Guest User

Untitled

a guest
May 25th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. //-----------------------------------------------------------------------
  2. // By: Matt White, 10-12-08, ITCS1212-001, ShipCost1.cpp
  3. // Purpose: User gives package weight, and is shown the shipment cost.
  4. //-----------------------------------------------------------------------
  5. #include <iostream>
  6. using namespace std;
  7. double GetShipCost(double dWeight);
  8.  
  9. int main(){
  10. double dWeight;
  11. cout << "Item Weight = "; cin >> dWeight;
  12. cout << "\n\tWeight: " << dWeight << "\n\tPrice: " << GetShipCost(dWeight);
  13. return 0;
  14. }
  15.  
  16. double GetShipCost(double dWeight){
  17. double dCost = 0; // Initial Cost
  18. double dAdd = 0; // Additonal amount added to initail cost
  19. int dLimit = 0; // The limit of when add extra $$ for each pound over (used in final cost calculation)
  20.  
  21. if (dWeight<5) {dCost=3; dLimit=0; dAdd = 0;}
  22. if (dWeight>=5 && dWeight<10) {dCost=3; dLimit=5; if (dWeight>5) dAdd = .25;}
  23. if (dWeight>=10 && dWeight<15) {dCost=5.50; dLimit=10; if (dWeight>10) dAdd = .20;}
  24. if (dWeight>=15) {dCost=8.50; dLimit=15; if (dWeight>15) dAdd = .10;}
  25.  
  26. return dCost + (dAdd*(dWeight-dLimit));
  27. }
  28.  
  29. // ----------------
  30. // Notes:
  31. // 1. GetShipCost uses numbers based on the directions given
  32. // ----------------
  33.  
  34. // ----------------
  35. // Directions:
  36. // 1. Include comment box with Name, Date, LectureNum, Filename, and app purpose. Include documentation & comments. Verify compilation.
  37. //
  38. // 2. Weight --> Cost Table:
  39. // Weight: under5 = 0-4 Add: 0 --> (None) = 0-4
  40. // Weight: [5,10) = 5-9 Add: .5 --> Over5 = 6-9
  41. // Weight: [10,15) = 10-14 Add: .20 --> Over10 = 11-14
  42. // Weight: 15&Over = 15-(+Inf) Add: .10 --> Over15 = 16+
  43. // ----------------
Add Comment
Please, Sign In to add comment