Question

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. 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, i.e., 600 miles is the same rate as 900 miles or 1000 miles.

Here are the shipping charges -

Package Weight                                                                                Rate per 500 miles shipped

  • Less than or equal to 10 pounds $3.00
  • More than 10 pounds but less than or equal to 50 pounds $5.00

If the shipping distance is more than 1000 miles, there is an additional charge of $10 per package shipped.

Test the cases below and make sure the answer is what it is

Test Case 1:

Input Data:

Weight:           1.5 pounds

Miles:              200 miles                                       (This is one 500 mile segment.)

Expected results: Your shipping charge is $3.00

Test Case 2:

Input Data:

Weight:           5.6 pounds

Miles:              1200 miles                                         (This is three 500 mile segments.)

Expected results: Your shipping charge is $19.00

Test Case 3:

Input Data:

Weight:           11.0 pounds

Miles:              2000 miles                                         (This is four 500 mile segments.)

Expected results:   Your shipping charge is $30.00

Test Case 4:

Input Data:

Weight:           38 pounds

Miles:              9600 miles                                          (This is twenty 500 mile segments.)

Expected results: Your shipping charge is $110.00

Test Case 5:

Weight:           55 pounds

Miles:              345 miles  

Expected results: Sorry, we only ship packages of 50 pounds or less.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*****************************Shipping.c*************************/

#include<stdio.h>
#include<math.h>
int main(){
  
   //variable declaration
   float weight,shippingCharge;
   int miles;
   //prompt for weight
   printf("Enter Weight: ");
   scanf("%f",&weight);
   //prompt for distance
   printf("Enter Distance(in miles): ");
   scanf("%d",&miles);
   //calculate shipping charge
   if(weight<=10&&miles<1000){
      
       shippingCharge = 3.0*ceil((float)miles/500);
       printf("Your shipping charge is $%.2f",shippingCharge);
   }
   else if(weight<=10&&miles>1000){
      
       shippingCharge = 3.0*ceil((float)miles/500)+10;
       printf("Your shipping charge is $%.2f",shippingCharge);
   }
   else if(weight>10&&weight<=50&&miles<1000){
      
       shippingCharge = 5.0*ceil((float)miles/500);
       printf("Your shipping charge is $%.2f",shippingCharge);
   }
   else if(weight>10&&weight<=50&&miles>1000){
      
       shippingCharge = 5.0*ceil((float)miles/500)+10;
       printf("Your shipping charge is $%.2f",shippingCharge);
   }
   else{
      
       printf("Sorry, we only ship packages of 50 pounds or less");
   }
  
   return 0;
}

/**************************output*********************/

Enter Weight: 38
Enter Distance(in miles): 9600
Your shipping charge is $110.00
--------------------------------

Please let me know if you have any doubt or modify the answer, Thanks :)

Add a comment
Know the answer?
Add Answer to:
Global Courier Services will ship your package based on how much it weighs and how far...
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
  • PSLAYER 09/27/2017 yo October 9,2017 Graduation st Monday at T2:43 AM Shipping Calculator: Global Courier Services...

    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...

  • 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...

  • 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. 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 each pound above 10 (make...

  • C programming only (Original work only as well, I will get into trouble if it is...

    C programming only (Original work only as well, I will get into trouble if it is a copy) also please add comments if it is not too much trouble. Program 5: Shipping Calculator The Speedy Shipping Company will ship packages based on how much they weigh and how far they are being sent. They will only ship small packages up to 10 pounds. You have been tasked with writing a program that will help Speedy Shipping determine how much to...

  • 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...

  • In this assignment, you will develop a C++ program which calculates a shipping charge and determines...

    In this assignment, you will develop a C++ program which calculates a shipping charge and determines the “type of trip” for a freight shipping company. Ask the user to enter the distance a package is to be shipped, and use a menu and a switch statement to determine the rate based on the package’s weight. Then display the shipping charge and using the table in #7 below, display the type of trip. Below is the chart to use to calculate...

  • IN C++ PROGRAMMING (We use #include <iostream> and cout and cin) Shipping Calculator Speedy Shipping Company...

    IN C++ PROGRAMMING (We use #include <iostream> and cout and cin) 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 world. They will only ship small packages up to 10 pounds. You need to have a program, which will help you determine how much they will charge. The charges are based on each 500 miles shipped. The mileage should be in whole...

  • C++ Lone Star Package Service ships packages within the state of Texas. Packages are accepted for...

    C++ Lone Star Package Service ships packages within the state of Texas. Packages are accepted for shipping subject to the following restrictions: Shipping requirements The package weight must not exceed 50 pounds. The package must not exceed 3 feet in length, width, or height. The girth of the package must not exceed 5 feet. The girth is the circumference around the two smallest sides of the package. If side1, side2, and side3 are the lengths of the three sides, and...

  • please Answer c (Cost of Shipment) Although a regional express delivery service bases the charge for shipping a package on the package weight and distance shipped, its profit per package depends...

    please Answer c (Cost of Shipment) Although a regional express delivery service bases the charge for shipping a package on the package weight and distance shipped, its profit per package depends on the package size (volume of space that it occupies) and the size and nature of the load on the delivery truck. The company recently conducted a study to investigate the relationship between the cost, y, of shipment (in dollars) and the variables that control the shipping charge- package...

  • My program works fine with if else conditions but when it is not working when I...

    My program works fine with if else conditions but when it is not working when I try to implement it using a for loop. Can you fix my for loop and please show me how to do this using loops? I would appreciate if you could explain the loop that you are using. /* Programming Challenge: Shipping Charges The Fast Freight Shipping Company charges the following rates: Weight of Package (in Kilograms) Rate per 500 Miles Shipped 2 kg or...

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