Question

In: Computer Science

Please use original C++ code for this. This is for visual studio. Program 5: Shipping Calculator...

Please use original C++ code for this. This is for visual studio.

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 charge per delivery.

The charges are based on each 500 miles shipped. Shipping charges are not pro-rated; i.e., 600 miles is the same charge as 900 miles; i.e., 600 miles is counted as 2 segments of 500 miles.

Here is the table they gave you:

Package Weight                                           Rate per 500 miles shipped

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.35

Test Case 1:

Input Data:

Weight:            1.5 pounds

Miles:              200 miles                                (This is one 500-mile segment.)

Expected result:

To ship a 1.5 pound package 200 miles, your shipping charge is $1.50.

Test Case 2:

Input Data:

Weight:            5.6 pounds

Miles:              1200 miles                              (This is three 500-mile segments.)

Expected result:

To ship a 5.6 pound package 1200 miles, your shipping charge is $11.10.

Test Case 3:

Weight:            1.0 pounds

Miles:              2500 miles                               (This is five 500-mile segments.)

Expected result:

To ship a 1.0 pound package 2500 miles, your shipping charge is $7.50.

Test Case 4:

Weight:            8.5 pounds

Miles:              12345 miles                            (This is twenty-five 500-mile segments.)

Expected result:

To ship a 8.5 pound package 12345 miles, your shipping charge is $133.75.

Test Case 5:

Weight:            12.8 pounds

Miles:              345 miles  

Expected result:

Sorry, we only ship packages of 10 pounds or less.

Hints: This program does not need any loops. The program will calculate one shipping charge and stop. Your test cases should test the various possibilities, and the limits of the program.

BIG Helpful Hint: You can use integer division. For example: 1200 / 500 = 2

Send email if you are stuck, or if there is something in this assignment that you are confused about.

Rubric:

Well-formatted code (indentation, use of whitespace, comments)

10%

Good variable names (proper case, meaningful identifiers)

10%

Good prompts (accurate, easy-to-use user interface)

10%

Calculations are correct

40%

Well-formatted output

10%

Screenshots showing your program running on your computer

20%

Solutions

Expert Solution

#include<iostream>

#include<iomanip>

#include <cmath>

using namespace std;

int main() {

    // declare variables

double weightOfPackage, shippingCost = 0;

int distanceInMiles, segments;

    // read weight

cout << "Input weight of the package: ";

cin >> weightOfPackage;

    // read distance

cout << "Input distance for the shipping in miles: ";

cin >> distanceInMiles;

// determine the segments

segments = ceil(distanceInMiles / 500.0);

    // fix the decimal precision to 2

cout << fixed << setprecision(2);

    // if weight is less than 2 pounds

if (weightOfPackage <= 2){

        // calculate cost

shippingCost = 1.5 * segments;

        // display result

cout << "To ship a " << weightOfPackage << " pound package " << distanceInMiles << " miles, your shipping charge is $" << shippingCost << endl;

}

    // if weight is between 2-6

else if (weightOfPackage > 2 && weightOfPackage <= 6){

        // calculate cost

shippingCost = 3.7 * segments;

        // display result

cout << "To ship a " << weightOfPackage << " pound package " << distanceInMiles << " miles, your shipping charge is $" << shippingCost <<endl;

}

    // if weight is between 6-10

else if (weightOfPackage > 6 && weightOfPackage <= 10) {

        // calculate cost   

shippingCost = 5.25 * segments;

        // display result

cout << "To ship a " << weightOfPackage << " pound package " << distanceInMiles << " miles, your shipping charge is $" << shippingCost << endl;

}

    // if weight is greater than 10

else {

cout << "Sorry, we only ship packages of 10 pounds or less." << endl;

}

return 0;

}


FOR HELP PLEASE COMMENT.
THANK YOU


Related Solutions

I need the code for following in C++ working for Visual studio please. Thanks Use a...
I need the code for following in C++ working for Visual studio please. Thanks Use a Struct to create a structure for a Player. The Player will have the following data that it needs maintain: Struct Player int health int level string playerName double gameComplete bool isGodMode Create the 2 functions that will do the following: 1) initialize(string aPlayerName) which takes in a playername string and creates a Player struct health= 100 level= 1 playerName = aPlayerName gameComplete = 0...
Please code in C#-Visual Studio Tasks The program needs to contain the following A comment header...
Please code in C#-Visual Studio Tasks The program needs to contain the following A comment header containing your name and a brief description of the program Output prompting the user for the following inputs: Name as a string Length of a rectangle as a double Width of a rectangle as a double Length of a square as an int After accepting user input, the program outputs the following: User name Area of a rectangle with dimensions matching the inputs Area...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that prompts the user to select a type of coffee she likes and 2) returns the object of what she selected to the console. #include "stdafx.h" #include <iostream> using namespace std; // Product from which the concrete products will inherit from class Coffee { protected:    char _type[15]; public:    Coffee()    {    }    char *getType()    {        return _type;   ...
PS: Please don't use #include <bits/stdc++.h>. Visual studio compatible please. Write a C++ program to find...
PS: Please don't use #include <bits/stdc++.h>. Visual studio compatible please. Write a C++ program to find least common multiple (LCM) of two, three and four integer values. The integer values are entered from the keyboard and the outputs are printed to the console. The LCM of two, three and four integer values are computed using Prime factorization method. You have to use arrays to hold input values and use functions/methods to get data from the keyboard, display output to the...
use VISUAL STUDIO CODE to write this javascript program Exercise 1 (a) Create a HTML file...
use VISUAL STUDIO CODE to write this javascript program Exercise 1 (a) Create a HTML file that uses createElement and appendChild to dynamically insert three paragraphs when a button is clicked. (b) Create a HTML file that includes JavaScript that is similar to: let recs = [“my item …1”,”my item…2”, …] i.e. an array that contains several CSV item records. When the user clicks a button, each array element will be rendered as a list element. Use a HTML list....
In Visual Studio in C#, you will create a simple calculator that performs addition, subtraction, multiplication,...
In Visual Studio in C#, you will create a simple calculator that performs addition, subtraction, multiplication, and division. Your program should request a numerical input from the user, followed by the operation to be performed, and the second number to complete the equation. The result should be displayed to the user after each equation is performed. For example, if the user performs 3+3, the program should display 6 as the result. The program should continue running so the user can...
In visual Studio C++ Create a program that uses a for loop to input the high...
In visual Studio C++ Create a program that uses a for loop to input the high temperature, and low temperature for each day of the week. The high and low will be placed into two elements of the array. For each loop the high and low will be placed into the next set of elements of the array. After the temps for all seven days have been entered into the array, a for loop will be used to pull out...
Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3...
Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3 text boxes: 2 of them to enter numbers, the 3rd one displays the results Create 4 buttons to add, subtract, multiply, and divide Prevent the user from entering text in the number fields Display a message indicating “cannot divide by” when the user click “/” and there is a zero the in the second box Create two additional buttons: - One to store data...
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a...
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a whole paragraph with punctuations (up to 500 letters) either input from user, initialize or read from file and provide following functionalities within a class: a)   Declare class Paragraph_Analysis b)   Member Function: SearchWord (to search for a particular word) c)   Member Function: SearchLetter (to search for a particular letter) d)   Member Function: WordCount (to count total words) e)   Member Function: LetterCount (ONLY to count all...
answer the following using C# Design and program a Visual Studio Console project in C# that...
answer the following using C# Design and program a Visual Studio Console project in C# that allows your user to enter a number. The program will examine the number to see if it is prime. If it is prime, it will print the next higher prime and the next lower primes to the console. If the number entered by the user is not prime, display a message to that effect. All code should be written by you. Do not copy/paste...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT