Saturday, March 10, 2012

Write an algorithm that will receive the weight of a parcel and determine the delivery charge for the parcel.?

Calculate the charges as follows:

Parcel Cost per kg($)

%26lt;2.5 kg 3.50 per kg

2.5-5 kg 2.85 per kg

%26gt;5kg 2.45kgWrite an algorithm that will receive the weight of a parcel and determine the delivery charge for the parcel.?
include %26lt;stdio.h%26gt;



int main(void){

float weight = 1.0, cost = 0.0;



printf("Enter the weight of the parcel: ");

scanf("%f", %26amp;weight);

if(weight %26lt; 2.5)

cost = weight * 3.5;

else if (weight %26gt;= 2.5 %26amp;%26amp; weight %26lt;= 5)

cost = weight * 2.85;

else if(weight %26gt; 5)

cost = weight * 2.45;

printf("Charge for this %.2f kg parcel = %.2f\n", weight, cost);

getchar();

getchar();

return 0;

}

No comments:

Post a Comment