Question

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 the shipping charges.

       Freight Shipping Company Rates

       ______________________________________________________________

       Weight of Package (pounds)           Rate per 500 miles shipped

       _______________________________________________________________

       10 pounds or less                    $1.10

       Over 10 pounds but not more than 20 $2.30

       Over 20 pounds but not more than 35 $3.60

       Over 35 pounds but not more than 50 $4.90

       _______________________________________________________________

       NOTICE: We do not ship packages over 50 pounds

               We do not ship less than 10 miles or more than 15,000 miles

Requirements for your program:

1.The output must be labeled and easy to read.

2.Validate that the distance can’t be less than 10 miles and more than 15,000 miles.

3.Use a logical operator when validating the distance to be shipped.

4.Display a menu of rate choices (similar to the chart above) so the user can choose the appropriate rate based on the package weight. Have the user enter a choice from the menu and use a switch statement to select and assign the rate.

5.Calculate the number of segments (a segment is 500 miles). Round uneven segments, i.e., segments not evenly divisible by 500, up to the next whole number (hint: use modulus or ceil).

6.There is a “long haul charge” of 50 cents per segment if the trip is over 20 segments.  

7.The shipping charge is the number of segments times the shipping rate plus any long haul charge.

8.Use “if-else” and/or “else-if” and/or “switch” statements to determine the “type of trip” based on the segments and this table:

1 to 10 segments: type of trip is a “short haul”

11 to 20 segments: type of trip is a “medium haul”

21 to 30 segments: type of trip is a “long haul”

Provide two screen prints:

the user enters 12,300 miles distance and selects a rate for shipping a 35 pound package.

The user enters 1,050 miles distance and selects a rate for shipping a 10 pound package.

Display:

-the distance entered

-the selected rate

-the number of segments

-the package’s shipping charge

-the “type of trip”

Submit:

Your .cpp file

Screen shot (s) of your output

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

---------------------------------------------------------.cpp---------------------------------------------------------

#include<bits/stdc++.h>

using namespace std;

int main(){

int distance,segment,type,weight;

cout<<"Freight Shipping Company Rates \n";

cout<<"-------------------------------------------------------\n";

cout<<"Weight of Package (pounds) Rate per 500 miles shipped\n";

cout<<"-------------------------------------------------------\n";

cout<<"10 pounds or less $1.10 \n";

cout<<"Over 10 pounds but not more than 20 $2.30 \n";

cout<<"Over 20 pounds but not more than 35 $3.60 \n";

cout<<"Over 35 pounds but not more than 50 $4.90 \n";

cout<<"-------------------------------------------------------\n";

cout<<"NOTICE: We do not ship packages over 50 pounds \n We do not ship less than 10 miles or more than 15,000 miles\n";

cout<<" \nEnter distance in miles: ";

cin>>distance;

cout<<"\n Enter package weight from the above rate menu: " ;

cin>>weight;

if(distance<10 or distance >15000){

cout<<"NOTICE: We do not ship less than 10 miles or more than 15,000 miles\n";

return 0;

}

segment = ceil(distance/500);

float rate =0;

// selectio of rate

if(weight <= 10 ) rate = 1.10;

else if( weight <= 20 ) rate = 2.30;

else if(weight <= 35 ) rate = 3.60;

else if(weight <= 50 ) rate = 4.90;

if(segment < 11 ) type =1;

else if(segment< 21 ) type = 2;

else if(segment <31) type =3;

float price = 0;

if(type == 3){

price = (segment * rate) + (segment *.5);

}

else{

price = (segment * rate) ;

}

cout<<"-the distance entered: "<<distance<<endl;

cout<<"-the selected rate: $"<<rate<<endl;

cout<<"-the number of segments: "<<segment<<endl;

cout<<"-the package's shipping charge: $"<<price<<endl;

cout<<"-the type of Trip :";

if(type==1) cout<<" short haul\n";

else if(type ==2 ) cout<<" medium haul\n";

else if(type ==3 ) {cout<<" long haul\n";

cout<<" Long haul chargers are also included @ 50 cents per segment ";

}

return 0;

}

--------------------------------------ends------------------------------------------------------

reight Shipping Company Rates eight of Package (pounds> 0 pounds or less Rate per 500 miles shipped $1.10 $2.30 3.60 4.90 Ove

reight Shipping Company Rates eight of Package (pounds> 0 pounds or less Rate per 500 miles shipped Over 10 pounds but not mo

Add a comment
Know the answer?
Add Answer to:
In this assignment, you will develop a C++ program which calculates a shipping charge and determines...
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
  • 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 C using (printf and scanf) Write a program to ask the user for the weight...

    In C using (printf and scanf) Write a program to ask the user for the weight of a package, and display the shipping charges for the package. If the weight of the package is less than or equal to 0 pounds, inform the user and exit the program. The shipping charges are: Weight of Package Shipping Charge 2 pounds or less $1.25 Over 2 pounds but not more than 6 pounds $2.50 Over 6 pounds but not more than 10...

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

  • Intro to C++ For this program, again use Program 4-18 in the text as an example....

    Intro to C++ For this program, again use Program 4-18 in the text as an example. Assume you're writing this menu-driven program for a shipping company. There are two types of shipments: normal and expedited. a. As shown in Program 4-18, please declare constants for the types of shipments. Please write the names of constants in ALL CAPS. b. Show the menu in a clear form, and prompt the user for the type of shipment; the rest of the program...

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

  • Can someone complete this program for me in c programming language? Thank you! The Send-Ex Shipping...

    Can someone complete this program for me in c programming language? Thank you! The Send-Ex Shipping Company charges the following rates: Weight of Package 2 lbs or less Over 2 lbs but no more than 6 lbs Over 6 lbs but no more than 10 lbs Over 10 lbs Rate per Pound $1.10 $2.20 $3.70 $4.10 Write a program that asks the user to enter the weight of a package and then displays the total shipping charge. Reserve Point Opportunity/...

  • C++ roblem 8 and 9 refer to the following description. A shipping company uses the following...

    C++ roblem 8 and 9 refer to the following description. A shipping company uses the following function to calculate the cost in dollars) of shipping based on the weight of the package (in pounds). c(w) = 2.48w, 0 <w<15 2.36w, 15 Sw< 45 2.24w, 45 Sw<75 2.12w, 75 Sw<90 Requirement for both problems: • If the weight is greater than 90, display a message the package cannot be shipped." . When the shipping cost is display, include the symbol (S)...

  • The Fast Freight Shipping Company charges the following rates: Weight of Package Rate per Pound 2...

    The Fast Freight Shipping Company charges the following rates: Weight of Package Rate per Pound 2 pounds or less $1.50 Over 2 pounds but not more than 6 pounds $3.00 Over 6 pounds but not more than 10 pounds $4.00 Over 10 pounds $4.75 Write a program that asks the user to enter the weight of a package then displays the shipping charges.

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

  • Python Language 3. Shipping Charges The Fast Freight Shipping Company charges the following rates (per 500...

    Python Language 3. Shipping Charges The Fast Freight Shipping Company charges the following rates (per 500 miles shipped): 1. Number Guessing Game Write a program for players to guess the number that the program randomly generated. Your program should randomly generate an integer between 1 and 10. After a player guessing a number, your program should display "Too small", "Too large", or "That's it!". Weight of Package (in Kilograms) 2 kg or less Over 2 kg but not more than...

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