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]
3 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]3 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
In early PCs, a DIMM in any one of the DIMM slots could fill the 64-bit bus; therefore, each slot was called a(n) ______________
Svetach [21]

Answer:

The correct answer to the following question will be Option A (Bank).

Explanation:

  • Sometimes on a motherboard, the memory modules are grouped into different groups and that each group is named as a branch. Furthermore, the term "bank" may be used loosely to describe a basic computing data storage area. When the record is stored in the database it can be accessed at a specific time by the user.
  • Because the 486 is a 32-bit processor and a 30-pin SIMM is 8-bit, four SIMMs (8x4=32) is called a bank when installing memory on an 80486 processor computer; Install four 16 MB SIMMs when upgrading to 64 MB. 

Therefore, Option A is the right answer.

3 0
3 years ago
A label control may be added to a form by double-clicking on the Label control icon in the ________ window.
Ierofanga [76]

Answer:

ToolBox.

Explanation:

A label control may be added to a form by double-clicking on the Label control icon in the ToolBox window.

5 0
3 years ago
When water reaches the pole, most of it turns to ice. Some salt is trapped between ice crystals, but most is left behind in the
astra-53 [7]

Answer:

b should be the right answer

Explanation:

8 0
3 years ago
Read 2 more answers
Emma wants to create a web page for her school’s volleyball team. Which of these could she use?
ser-zykov [4K]

Answer:

Emma should use Chrome

3 0
3 years ago
I don't understand how to write both. If I repeat the first code but with 3 and 6 it doesn't work.
hram777 [196]

It looks like you need to get both numbers from the input. Try doing something like this:

print(int(input()) + int(input()))

4 0
3 years ago
Other questions:
  • What does the Sort feature do with a database
    13·1 answer
  • Unlike images, tex and hyperlinks, vidoes _____ A) are playable in source view B are not used to affect user's emotions C) can b
    15·1 answer
  • Open and close ____ immediately following the name of a procedure identify a Visual Basic statement as a procedure call statemen
    6·1 answer
  • What is required for real-time surveillance of a suspects computer activity?/p Group of answer choices a. Blocking data transmis
    12·1 answer
  • The final step of the DHCP Discovery process is known as...
    8·1 answer
  • Which of the following is NOT true about digitizing physical media?
    10·1 answer
  • A bit pattern is shown below.<br> 01001110<br> Convert the bit pattern into decimal
    9·1 answer
  • Choose the accurate answer from the drop-down choices.
    11·1 answer
  • Which is a concept of the CIA of Computer Security
    7·1 answer
  • What does playstation network is currently undergoing maintenance?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!