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 numbers. They are not prorated, i.e., 600 miles is the same charge as 900 miles; in other words, 600 and 900 miles is counted as 2 segments of 500 miles each.
Here is the table they gave you:
|
Package Weight Rate per 500 miles shipped |
Charge |
|
2 pounds or less |
$1.50 |
|
More than 2 but not more than 6 |
$3.70 |
|
More than 6 but not more than 10 |
$5.25 |
Your code needs to validate the input completely, e.g., the weight and mile amounts must be positive. If an input is invalid, e.g., the weight is zero or less, you should display an appropriate, professional error message, e.g., Error: Weight must be greater than zero!, which should be offset and surrounded by white space, so it stands out, and repeat getting that input until valid input is received. Keep in mind, the user will find it annoying if they must enter both the miles and weight at the same time, and only one of them caused an error, or they must reenter already valid data. Also, make sure you follow the Code Conventions and good programming practices, e.g., appropriately initialize variables to zeros, avoid stacked if or if-else constructs unless necessary, don’t use break or continue to get out of a loop, goto, etc.; in other words, you should NOT used stacked if/if-else constructs, break, or continue for this assignment.
At this point for the code, you should only solve the problem using what you learned from modules 1 – 5, i.e., NO arrays, functions other than main(), etc. Only if all the input is valid, should the program calculate and display one shipping charge, and pause, but not quit, before proceeding to a new customer. Your test cases should test the various possibilities, and the limits of the program, which means, you will need to use an appropriate loop, which will ask if you would like to process the next customer or not by asking them to enter an appropriate value. Once there are no more customers to process, the program should display Good-bye! and end. Remember to solve each aspect of the program separately, and then, put the parts together.
Hints: You may need to reset any values after you display the answer and before you get the input for the next customer. Big Helpful Hint: For the number of segments calculation, you may want to start with integer division, e.g., 1200 miles / 500 miles per segment = 2 segments, and then, expand on that.
You should be able to solve this problem with only one loop.
Sample Run
Enter the number of miles as a whole number: 0
Error: Miles must be greater than zero!
Enter the number of miles as a whole number: 1
Enter the weight of the package in pounds: 0
Error: Weight must be greater than zero!
Enter the weight of the package in pounds: 1
The cost to ship your package is: $1.50.
Enter 1 to continue or 0 to quit: 1
Enter the number of miles as a whole number: 500
Enter the weight of the package in pounds: 2
The cost to ship your package is: $1.50.
Enter 1 to continue or 0 to quit: 1
Enter the number of miles as a whole number: 500
Enter the weight of the package in pounds: 2.5
The cost to ship your package is: $3.70.
Enter 1 to continue or 0 to quit: 1
Enter the number of miles as a whole number: 500
Enter the weight of the package in pounds: 6
The cost to ship your package is: $3.70.
Enter 1 to continue or 0 to quit: 1
Enter the number of miles as a whole number: 500
Enter the weight of the package in pounds: 11
Error: We don't ship packages over 10 pounds!
Enter the weight of the package in pounds: 10
The cost to ship your package is: $5.25.
Enter 1 to continue or 0 to quit: 1
Enter the number of miles as a whole number: 501
Enter the weight of the package in pounds: 3.75
The cost to ship your package is: $7.40.
Enter 1 to continue or 0 to quit: 1
Enter the number of miles as a whole number: 1000
Enter the weight of the package in pounds: 6.1
The cost to ship your package is: $10.50.
Enter 1 to continue or 0 to quit: 1
Enter the number of miles as a whole number: 12450
Enter the weight of the package in pounds: 1
The cost to ship your package is: $37.50.
Enter 1 to continue or 0 to quit: 0
Good-bye!
Press any key to continue . . .
Hey,Hey,Hey!!!!
Fasten your seat-belt!!!
I like to explain and express things in such a manner so that everybody can easily understand.
So, let’s dive deep into our solution:-
Here is the Program Code:-

OUTPUT:-


If you need the code,here it is:-
#include<iostream>
using namespace std;
int main(){
int choice;
int miles,segment;
double weight,charges,cost;
do
{
cout<<"Enter number of miles as whole number: ";
cin>>miles;
if(miles==0){
cout<<"Error: Miles must be greater than
zero!"<<endl;
cout<<"Enter number of miles as whole number:
";
cin>>miles;
}
cout<<"Enter the weight of the package in pounds: ";
cin>>weight;
if(weight==0){
cout<<"Error: Weight must be greater than
zero!"<<endl;
cout<<"Enter the weight of the package in
pounds: ";
cin>>weight;
}
if(weight>10){
cout<<"Error: We don't ship packages over 10
pounds!"<<endl;
cout<<"Enter the weight of the package in
pounds: ";
cin>>weight;
}
segment=miles/500;
if(miles%500 != 0){
segment=segment+1;
}
if(weight<=2){
charges=1.50;
}
if(weight>2 && weight<=6){
charges=3.70;
}
if(weight>6 && weight<=10){
charges=5.25;
}
cost=charges*segment;
cout<<"The cost to ship your package is:
$"<<cost<<endl;
cout<<"Enter 1 to continue or 0 to quit: ";
cin>>choice;
}while (choice!=0);
cout<<"Good-Bye!";
return 0;
}
Please give it a thumbs up,if you liked the answer.
IN C++ PROGRAMMING (We use #include <iostream> and cout and cin) Shipping Calculator Speedy Shipping Company...
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...
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...
PSLAYER 09/27/2017 yo October 9,2017 Graduation st Monday at T2:43 AM 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, ie, 600 miles is the same rate as 900 miles or...
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...
C++ Lone Star Package Service ships packages within the state of Texas. Packages are accepted for shipping subject to the following restrictions: Shipping requirements The package weight must not exceed 50 pounds. The package must not exceed 3 feet in length, width, or height. The girth of the package must not exceed 5 feet. The girth is the circumference around the two smallest sides of the package. If side1, side2, and side3 are the lengths of the three sides, and...
In C++ Assignment 7 - Postal Packages In the Gaddis textbook read Chapter 8 sections 8.1-8.10 and Chapter 9 section 9.1 before starting this assignment. Lone Star Package Service ships packages within the state of Texas. Packages are accepted for shipping subject to the following restrictions: Shipping requirements The package weight must not exceed 50 pounds. The package must not exceed 3 feet in length, width, or height. The girth of the package must not exceed 5 feet. The girth...
C++
with comments please!
// numberverifier.cpp
#include <iostream>
#include <exception>
using std::cout;
using std::cin;
using std::endl;
#include <cmath>
#include <cstring>
class nonNumber : public exception {
public:
/* write definition for the constructor */ -- Message is “An
invalid input was entered”
};
int castInput( char *s )
{
char *temp = s;
int result = 0, negative = 1;
// check for minus sign
if ( temp[ 0 ] == '-' )
negative = -1;
for ( int i...
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 >...
Python Language
3. Shipping Charges The Fast Freight Shipping Company charges the following rates (per 500 miles shipped): 1. Number Guessing Game Write a program for players to guess the number that the program randomly generated. Your program should randomly generate an integer between 1 and 10. After a player guessing a number, your program should display "Too small", "Too large", or "That's it!". Weight of Package (in Kilograms) 2 kg or less Over 2 kg but not more than...