Please find below the code, code screenshots and output screenshots. Please refer to the screenshot of the code to understand the indentation of the code. Please get back to me if you need any change in code. Else please upvote
CODE:
#include <iostream>
#include <iomanip>
//declaring constants for type of shipments
#define NORMAL 1
#define EXPEDITED 2
using namespace std;
int main()
{
int shipment_type = -1; //variable for shipment type
int flag = 0; //Variable for user input validation and initialize it to 0
double weight; //Variable for weight of the package
int distance; //Variable for distance
double cost; //Variable for cost
cout << "Enter 1 for normal shipments\nEnter 2 for expedited shipments\n";
cout << "\nEnter your type of shipment: ";
cin >> shipment_type; //reading the shipment type
//set flag as 1 if invalid shipemnt type entered
if(shipment_type != 1 && shipment_type != 2)
flag = 1;
//Reading the weight of packege
cout <<"Enter the weight of the package: ";
cin >> weight;
//Reading the distance
cout <<"Enter the distance: ";
cin >> distance;
//set flag as 1 if for normal shipment the distance is less than 15 and greater than 900
if(shipment_type == NORMAL && (distance < 15 || distance > 900))
flag = 1;
//set flag as 1 if for expedited shipment the distance is less than 10 and greater than 500
if(shipment_type == EXPEDITED && (distance < 10 || distance > 500))
flag = 1;
//calculate cost for normal shipment with weight less than or equal to 1
if(shipment_type == NORMAL && weight <= 1)
cost = distance * (2.03/100);
//calculate cost for normal shipment with weight greater than 1 and less than 4
if(shipment_type == NORMAL && weight > 1 && weight < 4)
cost = distance * (3.95/100);
//calculate cost for normal shipment with weight greater than or equal to 4 and less than 10
if(shipment_type == NORMAL && weight >= 4 && weight < 10)
cost = distance * (6.57/100);
//calculate cost for normal shipment with weight greater than or equal to 10
if(shipment_type == NORMAL && weight >= 10)
cost = distance * (8.26/100);
//calculate cost for expedited shipment with weight less than or equal to 1
if(shipment_type == EXPEDITED && weight <= 1)
cost = distance * (3.10/100);
//calculate cost for expedited shipment with weight greater than 1 and less than 4
if(shipment_type == EXPEDITED && weight > 1 && weight < 4)
cost = distance * (4.28/100);
//calculate cost for expedited shipment with weight greater than or equal to 4 and less than 10
if(shipment_type == EXPEDITED && weight >= 4 && weight < 10)
cost = distance * (7.13/100);
//calculate cost for expedited shipment with weight greater than or equal to 10
if(shipment_type == EXPEDITED && weight >= 10)
cost = distance * (9.75/100);
if(flag == 1) //display error if flag is 1
cout <<"\nThere was invalid input. Please try again.";
//displaying the shipment_type
if(flag == 0 && shipment_type == NORMAL)
cout <<"\n"<<setw(15) << left << "Shipment type" <<": " << setprecision(3) << fixed << "Normal";
if(flag == 0 && shipment_type == EXPEDITED)
cout <<"\n"<<setw(15) << left << "Shipment type" <<": " << setprecision(3) << fixed << "Expedited";
//displaying the Weight, Distance and cost
if(flag == 0){
cout <<"\n"<<setw(15) << left << "Weight" <<": " << setprecision(3) << fixed << weight;
cout <<"\n"<<setw(15) << left << "Distance" <<": " << distance;
cout <<"\n"<<setw(15) << left << "Cost" <<": $" << setprecision(2) << fixed << cost;
}
return 0;
}



OUTPUT:



Intro to C++ For this program, again use Program 4-18 in the text as an example....
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...
In C using (printf and scanf) Write a program to ask the user for the weight of a package, and display the shipping charges for the package. If the weight of the package is less than or equal to 0 pounds, inform the user and exit the program. The shipping charges are: Weight of Package Shipping Charge 2 pounds or less $1.25 Over 2 pounds but not more than 6 pounds $2.50 Over 6 pounds but not more than 10...
My program works fine with if else conditions but when it is not working when I try to implement it using a for loop. Can you fix my for loop and please show me how to do this using loops? I would appreciate if you could explain the loop that you are using. /* Programming Challenge: Shipping Charges The Fast Freight Shipping Company charges the following rates: Weight of Package (in Kilograms) Rate per 500 Miles Shipped 2 kg or...
write a program for C++ to use on Putty . C++ not Java The Fast Freight Company provides three kinds of shipping services for packages: regular, priority and overnight. They charge the following rates: Regular Priority Overnight <= 2 Kg $1.00 per Kg $3.50 per Kg $11.50 per Kg > 2 Kg but <=6 Kg $1.50 per Kg $5.50 per Kg $16.50 per Kg > 6 Kg but <=10 Kg $2.00 per Kg $7.50 per Kg $21.50 per Kg >...
IN C++ PROGRAMMING (We use #include <iostream> and cout and cin) 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 world. They will only ship small packages up to 10 pounds. You need to have a program, which will help you determine how much they will charge. The charges are based on each 500 miles shipped. The mileage should be in whole...
C++ programming I need at least three test cases for the program and at least one test has to pass #include <iostream> #include <string> #include <cmath> #include <iomanip> using namespace std; void temperatureCoverter(float cel){ float f = ((cel*9.0)/5.0)+32; cout <<cel<<"C is equivalent to "<<round(f)<<"F"<<endl; } void distanceConverter(float km){ float miles = km * 0.6; cout<<km<<" km is equivalent to "<<fixed<<setprecision(2)<<miles<<" miles"<<endl; } void weightConverter(float kg){ float pounds=kg*2.2; cout<<kg<<" kg is equivalent to "<<fixed<<setprecision(1)<<pounds<<" pounds"<<endl; } int main() { string country;...
Requirement Write pseudocode and translate it to ONE C-program for each the following problems. In your pseudocode and C-program, use only what you have learned in this class so far. (Menu) Design a menu for question 2 and 3. So far, you use one program to solve all lab questions. But some of you may feel awkward when you want to demo/test only one lab question. To overcome that, your program should show a menu so that the users of...
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...
C programming only (Original work only as well, I will get into trouble if it is a copy) also please add comments if it is not too much trouble. Program 5: Shipping Calculator The Speedy Shipping Company will ship packages based on how much they weigh and how far they are being sent. They will only ship small packages up to 10 pounds. You have been tasked with writing a program that will help Speedy Shipping determine how much to...
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...