1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
galben [10]
2 years ago
12

Write a program that asks for the weight of a package and the distance it is to be shipped. This information should be passed to

a calculateCharge function that computes and returns the shipping charge to be displayed . The main function should loop to handle multiple packages until a weight of 0 is entered.
Computers and Technology
1 answer:
larisa [96]2 years ago
7 0

Answer:

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

   const int WEIGHT_MIN   =    0,

             WEIGHT_MAX   =   20,

             DISTANCE_MIN =   10,

             DISTANCE_MAX = 3000;

   float package_weight,

         distance,

         total_charges;

   cout << "\nWhat is the weight (kg) of the package? ";

   cin >> package_weight;

   if (package_weight <= WEIGHT_MIN ||

       package_weight > WEIGHT_MAX)

   {

       cout << "\nWe're sorry, package weight must be\n"

            << " more than 0kg and less than 20kg.\n"

            << "Rerun the program and try again.\n"

            << endl;

   }

   else

   {

       cout << "\nDistance? ";

       cin >> distance;

       if (distance < DISTANCE_MIN ||

           distance > DISTANCE_MAX)

       {

           cout << "\nWe're sorry, the distance must be\n"       << "within 10 and 3000 miles.\n"

                << "Rerun the program and try again.\n"

                << endl;

       }

       else

       {

            if (package_weight <= 2)

               total_charges = (distance / 500) * 1.10;

           else if (package_weight > 2 &&

                   package_weight <= 6)

               total_charges = (distance / 500) * 2.20;

           else if (package_weight > 6 &&

                   package_weight <= 10)

               total_charges = (distance / 500) * 3.70;

           else if (package_weight > 10 &&

                   package_weight <= 20)

               total_charges = (distance / 500) * 4.80;

           cout << setprecision(2) << fixed

               << "Total charges are $"

               << total_charges

               << "\nFor a distance of "

               << distance

               << " miles\nand a total weight of "

               << package_weight

               << "kg.\n"

               << endl;

       }

   }

Explanation:

You might be interested in
A file extension of. Xlsm indicates what type of workbook.
Vitek1552 [10]

We have that the .xlsm <em>Format </em>is used to save Excel Macro-Enabled Workbook file

<h3>Formats</h3>

Generally file are saved in different formats for easy sorting and application on the operating system.

For instance if a music file is renamed and stored in a different format say .exe the audio file wont be recognised as an audio file and hence refuse to play.

e.g

  • .exe for a windows appication
  • ,mp3 for an audio file
  • .xlsm here is used to save Excel Macro-Enabled Workbook file

For more information on Excel visit

brainly.com/question/19295387

8 0
2 years ago
Write a program that displays a menu allowing the user to select air water, or steel. After the user has made a selection, the n
luda_lava [24]

Answer:

// Program is written in C++ Programming Language

// Comments are used for explanatory purpose

// Program starts here

#include<iostream>

using namespace std;

int main ()

{

// Declare Variable

int selection;

// Prompt user to make a selection of medium between air, water or steel.

cout<<"Make Selection"<<'\n'<<"Press 1 for Air"<<'\n'<<"Press 2 for Water"<<'\n'<<"Press 3 for Steel";

cin>>selection;

// Check for entry

if(selection == 1) {

cout<<"You selected Air"<<'\n';

cout<<"The distance travelled by sound wave in air is 1,125 feet in 1 second";

}

else if(selection == 2) {

cout<<"You selected Water"<<'\n';

cout<<"The distance travelled by sound wave in water is 4859 feet in 1 second";

}

else if(selection == 3) {

cout<<"You selected Steel"<<'\n';

cout<<"The distance travelled by sound wave in steel is 19554 feet in 1 second";

}

else

cout<<"Invalid Selection";

return 0;

}

7 0
3 years ago
What does the poster exemplify?
zloy xaker [14]

Answer:

try D

Explanation:

8 0
3 years ago
Read 2 more answers
Do you think that people accept poor quality in information technology projects and products in exchange for faster innovation?
ohaa [14]

Answer:

Explanation:

Great question, it is always good to ask away and get rid of any doubts that you may be having.

This depends on the company, but some companies will accept poor quality as long as the product works and provides them faster innovation. This will happen especially if a company knows or has an idea that a competitor is working on a similar product.

Another big reason why a company might accept poor quality in order to release a product is <u>money</u>. Sometimes a company does not have the budget to continue the project, therefore they release it usually in <u><em>Early Access</em></u>. This allows them to start making some money on the project while they continue to work on it.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

5 0
3 years ago
What is the main function of a file extension?
patriot [66]

To indicate which program is needed to open it

8 0
3 years ago
Other questions:
  • What is one advantage of top-down programming design?
    13·2 answers
  • Myles is studying a system to lessen the number of complaints about the Help Desk. He has formally studied the service counter a
    5·1 answer
  • Why is the ketboard calledQWERTY
    11·2 answers
  • Njdnkjsdnjvnsdjvnjsdnvjsdvnjdnvjdsnvnksn
    6·1 answer
  • An eReader has a 956-pixel x 1290-pixel grayscale display with each pixel able to display 32 shades of gray. What is the KiB siz
    9·1 answer
  • Write a code that takes numbers from the user as a list. (User can enter as many numbers as he wants). Then, find mean and stand
    15·1 answer
  • ~ I already know this ~ who was the bits victim in five nights at freddys 4 <br> ___10 points___
    12·2 answers
  • We cannot imagine a life without the Internet. Imagine that you had to live without being connected to the Internet. Discuss the
    13·1 answer
  • How to create create a database in mysql using clv files
    11·1 answer
  • This is a graded practice activity. This is not an actual quiz.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!