In: Computer Science
10. The cost of sending a package by an express delivery service is $16.00 for the first two pounds, and $6.00 for each extra pound or a fraction of a pound. If the package weighs more than 80 pounds, a $25.00 excess weight surcharge is added to the cost. No package over 180 pounds will be accepted. Write a program that accepts the weight of a package in pounds and computes the cost of mailing the package with proper messaging. It should handle the excessive package with a suitable excusing message. Write the program with if-else statements. Add to your report snapshots of the results for each range.
Write in C++
C++ Program pasted below.
#include <iostream>
using namespace std;
int main()
{int weight,cost;
cout<<"Enter the weight of the parcel in pounds:";
cin>>weight;
if(weight<=2)
{
cost=16;
cout<<"Cost of the parcel:$"<<cost;
}
else if(weight>3 && weight<=80)
{
cost=16+(weight-2)*6;
cout<<"Cost of the parcel:$"<<cost;
}
else if(weight>80 && weight<=180)
{
cost=16+(weight-2)*6+25;
cout<<"Cost of the parcel:$"<<cost;
}
else
cout<<"Sorry, Your parcel weight should be less than 180
pounds";
return 0;
}
Output Screen Test case 1
Output Screen Test case 2
Output Screen Test case 3
Output Screen Test case 4