In: Computer Science
I have to write a c program for shipping calculator. anything that ships over 1000 miles, there is an extra 10.00 charge. I have tried everything. no matter what I put, it will not add the 10.00. please help here is my code
#include <stdio.h>
#include <stdlib.h>
int main()
{
double weight, miles, rate, total;
printf("Enter the weight of the package:");
scanf("%lf", &weight);
if (weight > 50.0) {
puts("we only ship packages of 50 pounds or less.");
return 0;
}
if ( miles > 1000 ){
total = rate + 10.00;
printf("rate is $%.2lf \n", rate);
}
printf("Enter the amount of miles it would take:");
scanf("%lf", &miles);
if (weight <= 10.0)
rate = 3.00;
else
rate = 5.00;
printf("Shipping charge is $%.2lf \n", (int)((miles + 499.0) /
500.0) * rate);
if (miles >= 1000){
("shipping charge + 10.00");
}
system("pause");
}
** I request you to Please Provide the positive Rating**
SOURCE CODE:
#include <stdio.h>
#include <stdlib.h>
int main()
{
double weight, miles, rate;
printf("Enter the weight of the package:");
scanf("%lf", &weight);
if (weight <= 10.0)
rate = 3.00;
else
rate = 5.00;
if (weight > 50.0) {
puts("we only ship packages of 50 pounds or less.");
exit(0);
}
printf("Enter the amount of miles it would take:");
scanf("%lf", &miles);
if ( miles < 1000 ){
printf("Shipping charge is $%.2lf \n", (float)(((miles + 499.0) /
500.0) * rate));
}
else
{//total = rate + 10.00;
//printf("rate is $%.2lf \n", total);
printf("Shipping charge is $%.2lf \n", (float)(((miles + 499.0) /
500.0) * rate)+10);
}
return 0;
}
OUTPUT1:
Enter the weight of the package:46
Enter the amount of miles it would take:1254
Shipping charge is $27.53
OUTPUT2:
Enter the weight of the package:23
Enter the amount of miles it would take:780
Shipping charge is $12.79
OUTPUT3:
Enter the weight of the package:78
we only ship packages of 50 pounds or less.