Question: Problem Statement Write a program that takes input age(int type), price (double type) for a air ticket, category(char type). The program calculates the final price

Problem Statement

Write a program that takes input age(int type), price (double type) for a air ticket, category(char type). The program calculates the final price of the air ticket depending on the following criteria:

if age or price is less than or equal to ZERO, it should output Wrong input

if age is greater than 0 and less than or equal to 5

and if the category is neither A nor a, discount applied is 100%.

and if the category is either A or a, discount applied is 0%.

if age is greater than 5 and less than or equal to 12

and if the category is neither B nor b, discount applied is 50%.

and if the category is either B or b, discount applied is 0%.

if age is greater than 12 and less than or equal to 26

and if the category is neither C nor c, discount applied is 60%.

and if the category is either C or c, discount applied is 0%.

if age is greater than 26 and less than or equal to 60

and if the category is neither D nor d, discount applied is 70%.

and if the category is either D or d, discount applied is 0%.

if age is greater than 60

and if the category is neither E nor e, discount applied is 80%.

and if the category is either E or e, discount applied is 0%.

Your program should output the final price. You have to use both if and else statements to write your code.

Formula for calculating final price:

final_price = price - (( price * discount)/100) 

Hint: price is double. To print a double upto two place include the library iomanip and use the following syntax.

cout << fixed; cout << setprecision(2) << finalPrice; 

Input format: When you enter input in input box in zybooks:

The first input is the price

Second input is the age

Third input is the category

Output format:

It should print the final price depending on the age and category they are in.

The final price should be printed up till two decimal places.

If age or price is less than or equal to 0, program should just output Wrong input

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!