Answer to Question #35589 in C# for karuna tripathi

Question #35589
FlyHigh Airlines allows each passenger to carry limited amount of luggage per ticket. The
maximum amount of luggage that can be carried by a passenger depends on the class in which
the passenger is travelling. The following table lists the maximum amount of luggage allowed for
each class.
If a passenger carries luggage above the maximum amount permissible for the class in which
he/she is travelling in, the passenger is levied an additional cost at the rate of $2/additional KG.
Currently, this cost is calculated manually, which is a time consuming process. Therefore, the
management of FlyHigh Airlines has asked SoftSols Inc. to create an application that accepts the
total weight of a luggage carried by a passenger, checks whether it is more than the maximum
amount allowed for the passenger's class of travel, and then calculates the additional cost that
needs to be levied on the passenger. In addition, SoftSols Inc. needs to ensure that the application
is able to handle the weight of luggage in whole numbers as well as decimal numbers.
Write the code that SoftSols Inc. should use to create the desired application. [10 Marks]
Class Maximum Amount of
Luggage
First class 50 KGs
Business class 40 KGs
Economy class 20 KGs
1
Expert's answer
2017-02-24T07:43:07-0500
string class_of_travel;   // passenger's class of travel
double luggage_weight; //total weight of a luggage

double overweight; double additional_fee;

switch (class_of_travel)
{
case "First class":
overweight = luggage_weight-50;
break;
case "Business class":
overweight = luggage_weight-40;
break;
case "Economy class":
overweight = luggage_weight - 20;
break;
default:
//incorrect input
break;
}
if (overweight < 0) //no owerweight
additional_fee = 0;
else //owerweight
additional_fee = overweight * 2;

// result is additional_fee

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
27.11.13, 14:46

You're welcome. We are glad to be helpful. If you really liked our service please press like-button beside answer field. Thank you!

anjana anant
26.11.13, 18:57

it's very helpful thanku

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS