Question

PSLAYER 09/27/2017 yo October 9,2017 Graduation st Monday at T2:43 AM Shipping Calculator: Global Courier Services will ship your package based on how much it weighs and how far you are sending the package. Packages above 50 pounds will not be shipped. You need to write a program in C that calculates the shipping charge The shipping rates are based on per 500 miles shipped. They are not pro-rated, ie, 600 miles is the same rate as 900 miles or 1000 miles. Here are the shipping charges- Package Weight Less than or equal to 10 pounds2 $2.00 More than10 pounds but less than or equal to 50 pounds S450 Here are some test cases. Test Case 1: Input Data Weight: 1.5 pounds Miles: 200 miles (This is one 500 mile segment.) Expected results: Your shipping charge is $2.00 Test Case 2: Input Data: eight: 5.6 pounds Miles: 1200 miles (This is three 500 mile segments) Expected results: Your shipping charge is $6.00 October 11, 2017 丶 Graduation started a call. Teda, at 26 PM
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

int main()
{
// Declaring the variables
float weight, shippingcost;
int miles;


// getting the value of weight entered by the user
printf("weight (in Pounds):");
scanf("%f", &weight);

/* If the weight is more than 50 pounds
* then it will not be delivered
*/
if (weight > 50)
{
printf("** Overweight.This package will not be shipped **\n");
}
else
{
// Getting the miles entered by the user
printf("Miles :");
scanf("%d", &miles);

// Based on weight and no of miles calculating the shipping cost
if (weight <= 10)
{
if (miles < 500)
{
shippingcost = 2;
}
else if (miles >= 500)
{
shippingcost = (miles / 500) * 2;
if (miles % 500 < 500 && miles % 500 != 0)
shippingcost += 2;
}
}
else if (weight > 10 && weight <= 50)
{
if (miles < 500)
{
shippingcost = 4.50;
}
else if (miles >= 500)
{
shippingcost = (miles / 500) * 4.50;
if (miles % 500 < 500 && miles % 500 != 0)
shippingcost += 4.50;
}
}

// Displaying the shipping cost
printf("Your Shipping Charge is :$ %.2f", shippingcost);
}


return 0;
}

___________________

Output:

C:Program Files (x86)\Dev-CpplMinGW641bin ShippingCostBasedWeightAndDistancelnMiles.exe weight in Pounds> :55 ** Overweight.T

_____________Could you rate me well.Plz .Thank You

Add a comment
Know the answer?
Add Answer to:
PSLAYER 09/27/2017 yo October 9,2017 Graduation st Monday at T2:43 AM Shipping Calculator: Global Courier Services...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Global Courier Services will ship your package based on how much it weighs and how far...

    Global Courier Services will ship your package based on how much it weighs and how far you are sending the package. (visual studio or dev c) You need to write a design tool and a program in C that calculates the shipping charge based on weight and distance and the total cost. The shipping rates are as follows: BASED ON WEIGHT Charge 10 dollars for all package weighing 10 pounds or less Charge an additional 2 dollars per pound for...

  • C PROGRAMMING Introduction In this part, you will solve a problem described in English. Although you...

    C PROGRAMMING Introduction In this part, you will solve a problem described in English. Although you may discuss ideas with your classmates, etc., everyone must write and submit their own version of the program. Do NOT use anyone else’s code, as this will result in a zero for you and the other person! Shipping Calculator Speedy Shipping Company will ship your package based on the weight and how far you are sending the package, which can be anywhere in the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT