Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I cannot figure out why it wont run. Please help Shipping Calculator: Global Courier Services will ship your package based on how much it weighs

I cannot figure out why it wont run. Please help

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

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

// This program will calculate the shipping charges.// 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.

#include

#include

main()

{

double packageWeight, packageDistance, packagePrice;

int packageDistanceMath;

printf("Enter the weight of the package: ");

scanf_s("%lf", &packageWeight);

printf("The weight you have entered is %.2lf ", packageWeight);

// A package that weighs less than 10lbs will cost $3

if (packageWeight <= 10)

packagePrice = 3.00;

// A package that weighs less than or equal to 50lbs but more than 10lbs will cost $5.00

if (packageWeight <= 50 && packageWeight > 10)

packagePrice = 5.00;

// Do not ship packages weighing more than 50lbs

if (50 <= packageWeight) {

printf("The package will not ship. ");

system("pause");

}

printf("How far are you sending the package? ");

scanf_s("%lf", &packageDistance);

printf("The distance you entered is %.2lf ", packageDistance);

// 200 miles will cost the same as 500 miles

// The milage is not pro-rated

if (packageDistance < 500) {

packageDistance = 1;

packagePrice = packageDistance * packagePrice;

printf("The shipping charge is %.2lf ", packagePrice);

system("pause");

}

packageDistanceMath = (packageDistance / 500);

packagePrice = packageDistanceMath * packagePrice;

printf("The shipping charge is %.2lf ", packagePrice);

system("PAUSE");

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+ 2. How well known are his/her credentials to the audience?

Answered: 1 week ago