What is wrong with my loop/calculations?

I'm not getting the right output, I'm getting integers instead of a dollar amount when my loop fully executes. My output is showing how many items I'm entering instead of the sum of the cost to ship the items entered. I'm just a beginner here. What am I missing/what should I change?

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
int kilograms = 0;
    int distance = 0;
    double cost = 0;
     
     
     
    do
    {
        cout << "Please enter the weight of the package" << endl;
        cin >> kilograms;
        cout << "Please enter the distance of shipment" << endl;
        cin >> distance;
        cost = cost + kilograms;
    } 
        while (kilograms !=0);
    cout << "Your total to ship these item(s) will be: " << total << endl;
         
    calculateCharge(kilograms, distance);
 
    if (kilograms <= 2)
        cost = 3.10 * (distance / 500);
    else if (kilograms >= 3 && kilograms <= 6)
        cost = 4.20 * (distance / 500);
    else if (kilograms >= 7 && kilograms <= 10)
        cost = 5.30 * (distance / 500);
    else if (kilograms > 10)
        cost = 6.40 * (distance / 500);
 
    return 0;
well your if statements calculate cost, but in line 13 your also calculating cost.

Seems like a logic problem, in other words you need to rethink your logic, IE math.
Can you give me any other hints? I took out the calculation on line 13, i can see now that it doesn't seem necessary. I'm really struggling here.
Topic archived. No new replies allowed.