Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. //global variables
  6. double totalDistance;
  7. double variableCosts;
  8. double shippingCost;
  9. double finalShippingCost;
  10. double n1, n2, n3, n4, n5, n6, n7, n8;
  11.  
  12. int main()
  13.  
  14. {
  15. void validDistance();
  16. void calcVariableCosts();
  17. const char poundSign(156);
  18.  
  19. cout << "Enter the distance in miles:";
  20. cin >> totalDistance;
  21.  
  22. validDistance();
  23.  
  24. calcVariableCosts();
  25.  
  26. shippingCost + 50 == finalShippingCost;
  27.  
  28. cout.setf(ios::fixed);
  29. cout << setprecision(2);
  30. cout << "The cost of the shipment over " << totalDistance << "miles is " << poundSign << finalShippingCost << "\n";
  31.  
  32.  
  33. system("pause");
  34. return (0);
  35. }
  36.  
  37. void validDistance()
  38. {
  39. if (totalDistance <= 0)
  40. {
  41. cout << "ERROR: The distance should be a positive value" << "\n";
  42.  
  43. }
  44. else
  45. {
  46. (totalDistance > 0);
  47.  
  48. }
  49.  
  50. }
  51.  
  52. void calcVariableCosts()
  53. {
  54. if (totalDistance <= 100)
  55. {
  56. totalDistance * 5.5 == shippingCost;
  57. }
  58. else if (totalDistance > 100 && totalDistance <= 500)
  59. {
  60. totalDistance - 100 == n1;
  61. 100 * 5.5 == n2;
  62. n1 * 4 == n3;
  63. n2 + n3 == shippingCost;
  64. }
  65. else if (totalDistance > 500)
  66.  
  67. {
  68. totalDistance - 100 == n4;
  69. n4 - 400 == n5;
  70. 100 * 5.5 == n6;
  71. 400 * 4.0 == n7;
  72. n2 * 2.5 == n8;
  73. n6 + n7 + n8 == shippingCost;
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement