Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-----------------------------------------------------------------------
- // By: Matt White, 10-12-08, ITCS1212-001, ShipCost1.cpp
- // Purpose: User gives package weight, and is shown the shipment cost.
- //-----------------------------------------------------------------------
- #include <iostream>
- using namespace std;
- double GetShipCost(double dWeight);
- int main(){
- double dWeight;
- cout << "Item Weight = "; cin >> dWeight;
- cout << "\n\tWeight: " << dWeight << "\n\tPrice: " << GetShipCost(dWeight);
- return 0;
- }
- double GetShipCost(double dWeight){
- double dCost = 0; // Initial Cost
- double dAdd = 0; // Additonal amount added to initail cost
- int dLimit = 0; // The limit of when add extra $$ for each pound over (used in final cost calculation)
- if (dWeight<5) {dCost=3; dLimit=0; dAdd = 0;}
- if (dWeight>=5 && dWeight<10) {dCost=3; dLimit=5; if (dWeight>5) dAdd = .25;}
- if (dWeight>=10 && dWeight<15) {dCost=5.50; dLimit=10; if (dWeight>10) dAdd = .20;}
- if (dWeight>=15) {dCost=8.50; dLimit=15; if (dWeight>15) dAdd = .10;}
- return dCost + (dAdd*(dWeight-dLimit));
- }
- // ----------------
- // Notes:
- // 1. GetShipCost uses numbers based on the directions given
- // ----------------
- // ----------------
- // Directions:
- // 1. Include comment box with Name, Date, LectureNum, Filename, and app purpose. Include documentation & comments. Verify compilation.
- //
- // 2. Weight --> Cost Table:
- // Weight: under5 = 0-4 Add: 0 --> (None) = 0-4
- // Weight: [5,10) = 5-9 Add: .5 --> Over5 = 6-9
- // Weight: [10,15) = 10-14 Add: .20 --> Over10 = 11-14
- // Weight: 15&Over = 15-(+Inf) Add: .10 --> Over15 = 16+
- // ----------------
Add Comment
Please, Sign In to add comment