Calculating Rate of Shipping Company program


The Fast Freight Shipping Company charges the following rates:
Weight of Package (in Kilograms) Rate per 500 Miles Shipped
2 Kg or less $1.10
Over 2 Kg but not more than 6 Kg $2.20
Over 6 Kg but not more than 10 Kg $3.70
Over 10 Kg but not more than 20 Kg $4.80


make sure the user entered a correct weight
make sure the user entered a correct distance

This is what I have. I have no idea what I'm doing wrong or how to
fix it. Please help.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  #include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	double weightOfPackage,
			miles,
			rate;

	cout << "What is the weight of your package (in kilograms)? ";
	cin  >> weightOfPackage;

	if (weightOfPackage <= 0)
		{
			cout << endl;
			cout << "Weight cannot be '0' kilograms. " << endl;
			cout << "You must run the program again. " << endl;
			return 0;
		}

		else if (weightOfPackage > 20)
		{
			cout << endl;
			cout << "We do not accept weights of more than 20 kg" << endl;
			cout << "You must run the program again" << endl;
			return 0;
		}

		else if (weightOfPackage >= 1  && weightOfPackage <= 20 )
		{
			cout << endl;
			cout << "Enter the distance the package will be shipped" << endl;
			cout << "(in miles): ";
			cin  >> miles;
		}
		else if (miles < 10 || miles > 3000)
			{	
				cout << endl;
				cout << "The distance entered is out of our shipping range." << endl;
				cout << "We do not accept distances of less than 10 miles" << endl;
				cout << "and no more than 3,000 miles. " << endl;
				cout << endl;
				cout << "You must run the program again. " << endl;
				return 0;
			}
		else if (weightOfPackage > 0 && weightOfPackage <= 2)
		rate = 1.10;
		
		else if (weightOfPackage > 2 && weightOfPackage <= 6)
		rate = 2.20;
		
		else if (weightOfPackage > 6 && weightOfPackage <= 10)
		rate = 3.70;
		
		else if (weightOfPackage > 10 && weightOfPackage <= 20)
		rate = 4.80;

		else if (miles > 10 && miles < 500)
		miles = 1;
		else if (miles > 500 && miles < 1000)
		miles = 2;
		else if (miles > 1000 && miles < 1500)
		miles = 3;
		else if (miles > 1500 && miles < 2000)
		 miles = 4;
		else if (miles > 2500.0 && miles <= 3000)
		miles = 5;
	
		
		cout << "The shipping charges for your order is $" << weightOfPackage * rate * miles << endl;

 
		
	
	


	return 0;
}
closed account (48T7M4Gy)
I have no idea what you are doing wrong either, excluding your original statement on that subject of course. :)
Topic archived. No new replies allowed.