Question

roblem 8 and 9 refer to the following description. A shipping company uses the following function to calculate the cost in do

C++

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

CODE:

#include <iostream>

using namespace std;

int main()
{
//create two variables one to store the weight and other for calculating the shipping cost
float weight, shippingCost=0;
//ask how much is the weight
cout<<"How much weight is the package?";
//get teh weight
cin>>weight;
/*
check for the boundary conditions.
If it is greater than or equal to 90 then print package cannot be shipped
*/
if(weight >=90)
cout<<"\nThe package cannot be shipped";
//if the weight is less than 0 then given wrong input
else if(weight<0)
cout<<"\nGiven wrong weight. Please try again.";
  
/***********start checking for the functions*************/
  
//if weight is between 0 and 15 then get the appropriate function
else if(weight>=0 && weight<15)
{
//multiply with the correct weight and store it as shipping cost
shippingCost = 2.48*weight;
//printing the shipping cost with 2 decimal precision
printf("\nShipping cost is: $%.2f",shippingCost);
}
  
//if weight is between 15 and 45 then get the appropriate function
else if(weight>=15 && weight<45)
{
//multiply with the correct weight and store it as shipping cost
shippingCost = 2.36*weight;
//printing the shipping cost with 2 decimal precision
printf("\nShipping cost is: $%.2f",shippingCost);
}
  
//if weight is between 45 and 75 then get the appropriate function
else if(weight>=45 && weight<75)
{
//multiply with the correct weight and store it as shipping cost
shippingCost = 2.24*weight;
//printing the shipping cost with 2 decimal precision
printf("\nShipping cost is: $%.2f",shippingCost);
}
  
//if weight is between 75 and 90 then get the appropriate function
else if(weight>=75 && weight<90)
{
//multiply with the correct weight and store it as shipping cost
shippingCost = 2.12*weight;
//printing the shipping cost with 2 decimal precision
printf("\nShipping cost is: $%.2f",shippingCost);
}
return 0;
}

OUTPUT:

10:

How much weight is the package?10 Shipping cost is: $24.80 ... Program finished with exit code 0 Press ENTER to exit console.

20:How much weight is the package?20 Shipping cost is: $47.20 ... Program finished with exit code o Press ENTER to exit console.

50:

How much weight is the package?50 Shipping cost is: $112.00 ... Program finished with exit code o Press ENTER to exit console

80:

How much weight is the package?80 Shipping cost is: $169.60 ... Program finished with exit code 0 Press ENTER to exit console

-5:

How much weight is the package?-5 Given wrong weight. Please try again. ... Program finished with exit code 0, Press ENTER to

95:

How much weight is the package?95 The package cannot be shipped ... Program finished with exit code 0, Press ENTER to exit co

Add a comment
Know the answer?
Add Answer to:
C++ roblem 8 and 9 refer to the following description. A shipping company uses the following...
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
  • 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...

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

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

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

  • Write a C++ program that uses: .selection constructs (if, if else, and switch) .multiway branches .looping...

    Write a C++ program that uses: .selection constructs (if, if else, and switch) .multiway branches .looping constructs (do and while loops) .Boolean expressions, bool and char types. 1. Develop a program that calculates charges for an Internet provider. The cost is determined by the amount of data used and the consumer plan. Package B (basic) is the most affordable if you plan on using < 20GB (20,000MB), however, if you consume more than 20GB (20,000MB) you are charged for each...

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

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

  • 1. Evaluate the following expressions if p = 8, 9 = 3, and the value of...

    1. Evaluate the following expressions if p = 8, 9 = 3, and the value of the variable found is False. Show your work. . q <= p . not (p == 4-5) . q != p % 5 . found or p > 5 and q == p + 5 2. Are you able to draw the truth tables for AND, OR, and NOT logical expressions? - Translate the following problem descriptions into Python. 3. If score is greater...

  • Please can someone help me to finish this program? It is a C programming not a...

    Please can someone help me to finish this program? It is a C programming not a C++, when programming the program in linux I keep getting expected expression before || token, also please check if everything else is fine, maybe there is something else worng in my program and may ask me later to fix it, I am concern about the sin and cosine. The program is supposed to do all this: 1.Display a welcome message. 2.Prompt for the height...

  • The first programming project involves writing a program that computes the minimum, the maximum and the...

    The first programming project involves writing a program that computes the minimum, the maximum and the average weight of a collection of weights represented in pounds and ounces that are read from a data file. This program consists of two parts. The first part is the Weight class and the second part is the Program Core. The Weight Class is specified in integer pounds and ounces stored as a double precision floating point number. It should have five public methods...

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