//Jacklyn Isordia CSC5 Chapter 4, P. 222, #13
//
/**************************************************************
*
* Calculate the charges of the fast freight shipping
* ____________________________________________________________
*
* This program asks the user to enter a weight and distance
* and then displays the charges of the fast freight shipping.
* ____________________________________________________________
* INPUT
* weight : weight of the package in kilograms
* distance : distance to ship the package in miles
*
* OUTPUT
* charges : the total shipping charge in dollars
*
**************************************************************/
#include <iostream>
using namespace std;
int main() {
int weight;
double distance;
double charges;
cout << "Enter the weight of the package (kg): ";
cin >> weight;
cout << "Enter the distance of the package: ";
cin >> distance;
while (weight <= 0 || weight > 20)
{
cout << "Invalid! Enter a weight between 1 and 20 kg: ";
cin >> weight;
}
while (distance < 10 || distance > 3000)
{
cout << "Invalid! Enter a distance beteen 10 and 3000 miles: ";
cin >> distance;
}
if (weight <= 2)
charges = (distance / 500.0) * 1.10;
else if (weight <= 6)
charges = (distance /500.0) * 2.20;
else if (weight <= 10)
charges = (distance / 500.0) * 3.70;
else
charges = (distance / 500.0) * 4.80;
cout << "The shipping charge is: $" << charges << endl;
return 0;
}