Question

C++ :The Fast Freight Company charges the following rates: Weight of Package (in Kilograms) Rate per...

C++ :The Fast Freight Company charges the following rates: Weight of Package (in Kilograms) Rate per 500 Miles shipped 2 Kg or less $1.10 Over 2 Kg but not more than 6 Kg $2.35 Over 6 Kg but not more than 10 Kg $3.70 Over 10 Kg but not more than 20 Kg $4.80 Write a program that asks for the weight of the package and the distance it is to be shipped, and then display the charges. Input Validation: Do not accept values of 0 or less for the weight of the package. Do not accept weights of more than 20 Kg (this is maximum weight the company will ship). Do not accept distances of less than 10 miles or more than 3,000 miles. These are company’s minimum and maximum shipping distances. The program should have the capability to process multiple set of shipping data. Use a do..while statement with the prompt message "Do you want to enter another set? (Y/N)” You will incorporate an Error trap code to validate the (Y/N) response

Homework Answers

Answer #1

#include<iostream>

using namespace std;

double charge(double);

int main()

{

char choice;

int flag;

double weight,distance,charges,rate;

do

{

flag=0;

while(flag==0)

{

cout<<"enter weight of the packet:";

cin>>weight;

if(weight>0) flag=1;

}

flag=0;

while(flag==0)

{

cout<<"\nenter distance :";

cin>>distance;

if(distance>=10&&distance<=3000) flag=1;

}

rate=charge(weight);

if(distance>=10&&distance<500)

{

charges=rate;

}

else if(distance>=500&&distance<1000)

{

charges=2*rate;

}

else if(distance>=1000&&distance<1500)

{

charges=3*rate;

}

else if(distance>=2000&&distance<2500)

{

charges=4*rate;

}

else

{

charges=5*rate;

}

cout<<"\nthe chages for weight "<<weight<<" and distance "<<distance<<" is "<<charges;

cout<<"\ndou you want to continue:";

cin>>choice;

}while(choice=='Y'||choice=='y');

}

double charge(double weight)

{

if(weight<2) return 1.10;

else if(weight>=2&&weight<6) return 2.35;

else if(weight>=6&&weight<10) return 3.70;

else return 4.80;

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In c++ format please Bank Charges A bank charges $10 per month plus the following check...
In c++ format please Bank Charges A bank charges $10 per month plus the following check fees for a commercial checking account: $.10 each for fewer than 20 checks $.08 each for 20–39 checks $.06 each for 40–59 checks $.04 each for 60 or more checks The bank also charges an extra $15 if the balance of the account falls below $400 (before any check fees are applied). Write a program that asks for the beginning balance and the number...
Question 5: Assume that you make candy bars; the advertised weight of the candy bar is...
Question 5: Assume that you make candy bars; the advertised weight of the candy bar is 4.0 ounces with a standard deviation (sigma) of 2.35 oz. however your production manager thinks that this is not true; he thinks the candy bars are over-weight, they weigh more than 4.0 oz. To test his claim, you decided to randomly select a sample of 126 candy bars, the average weight (x-bar) is 4.5 oz. At an alpha (a) of 0.01 what do you...
Business Problem-Solving Case Walmart and Amazon Duke It Out for E-Commerce Supremacy Walmart is the world’s...
Business Problem-Solving Case Walmart and Amazon Duke It Out for E-Commerce Supremacy Walmart is the world’s largest and most successful retailer, with $487.5 billion in 2014 sales and nearly 11,000 stores worldwide, including more than 4,000 in the United States. Walmart has 2.2 million employees and ranks first on the Fortune 500 list of companies. Walmart had such a large and powerful selling machine that it really didn’t have any serious competitors—until now. Today, Walmart’s greatest threat is Amazon.com, often...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...