131k views
3 votes
(11 pts) Cost of shipping: Write, compile, and test a C++ program that uses an if-else structure for problem 3.11 on page 108. Use the format specified earlier (initial block of comments with TCC logo, name, description, etc.) Display clear instructions so that the user understands the purpose of the program and what to enter. When the shipping cost is display, include the symbol ($). Run the program for the following 6 cases: 1 weight in each of the valid ranges (4 cases) 1 negative weight (display an appropriate message) 1 weight over 20 lb (not 50 as the text states) with the message indicated in the text Turn in a printout of the program and printouts of the 3 test cases.

User Thejh
by
4.7k points

1 Answer

6 votes

Answer:

C++ code for the problem given below

Step-by-step explanation:

#include<iostream>

#include <conio.h>

using namespace std;

void main()

{

double weight;

cout<<"Enter the weight of the package ";

cin>>weight;

if(weight>0 && weight<1)

cout<<"The shipping cost is $"<< 3.5*weight ;

else if(weight>1 && weight<3)

cout<<"The shipping cost is $"<<5.5*weight;

else if(weight<10 && weight>3)

cout<<"The shipping cost is $"<<8.5*weight;

else if(weight<20 && weight>10)

cout<<"The shipping cost is $"<<10.5*weight;

else if(weight< 0)

cout<<"Enter a valid weight as the weight cannot be negative";

else if(weight >20)

cout<<"The package cannot be shipped;

getch();

}

User Savan Padaliya
by
5.2k points