Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

In Problem find f (x) and simplify. f(x) = (3x + 2)(4x - 5)

Answered: 1 week ago

Question

1. Understand how verbal and nonverbal communication differ.

Answered: 1 week ago

Question

Solve for x: 2(3x 1)2(x + 5) = 12

Answered: 1 week ago