So my assignment is calculating shipping costs. But in the problem, it states that the shipping rates are based on per 500 miles shipped. (Example - if the number of miles is 2000, it will be rate * 4).
How do I write this part up? Thanks. I can't figure it out.
If you need more information, please ask.
Edit: I tried a code but it does not work properly:
Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
double weight, miles, distanceRate, rate, shippingCharge;
// User enters the weight and mileage
printf("Enter the weight of the package:");
scanf("%lf", &weight);
printf("Enter the amount of miles it would take:");
scanf("%lf", &miles);
// Find the shipping rate and charge when based on per 500 miles
distanceRate = (miles / 500) + 1;
shippingCharge = distanceRate * rate;
// When the weight is greater than 50
if (weight > 50); {
printf("Sorry, we only ship packages of 50 pounds or less.");
}
// When the weight is less than or equal to 10
if (weight <= 10) {
rate = 2.00;
printf("Shipping charge is $ %lf \n", shippingCharge);
}
// When the weight is greater than 10 but less than or equal to 50
else
if(weight > 10) {
rate = 4.50;
printf("Shipping charge is %lf \n", shippingCharge);
}
else(weight <= 50); {
rate = 4.50;
printf("Shipping charge is %lf \n", shippingCharge);
}
system("pause");
}