The Transportation Company calculates the freight for the user. the longer the distance, the lower the freight rate per kilometer. the basic freight per kilometer per ton is P = 3, the weight is W, the distance is S, the discount is d, the formula for calculating total freight F is f = p * w * S * (1-D ). The discount rules are as follows:
S <250 km no discount
250 <S <500 2% discount
500 <S <1000 5% discount
1000 <S <2000 8% discount
2000 <S <3000 10% discount
3000 <s 15% discount
Please write a program to automatically calculate the total freight when the user informs the weight of the goods and the distance between transportation.
# Include <stdio. h>
Void main ()
{
Double P = 3;
Double W, S, D, F;
Printf ("Enter the cargo weight and transportation distance (separated by a number): \ n ");
Scanf ("% lf, % lf", & W, & S );
If (s <= 250)
{
D = 0;
}
Else if (S> 250 & S <= 500)
{
D = 2/100;
}
Else if (S> 500 & S <= 1000)
{
D = 5/100;
}
Else if (S> 1000 & S <= 2000)
{
D = 8/100;
}
Else if (s >= 3000)
{
D = 15/100;
}
F = p * w * S * (1-D );
Printf ("total freight for shipping goods: %. 2lf RMB \ n", F );
}