4. Nested Logic Use program TicketPrice for exercises 6-7. // Program TicketPrice prints the price for a ticket to // the Wonderland park based on an age input from the keyboard #include using namespace std; int main () int age; cout <« "Welcome to Wonderland Park! Please enter your age:" << endl; cin >> age; if ( age <= 3 ) cout << "Children under 3 can enjoy free admission. " « endl; /* TO BE FILLED IN FOR EXERCISE 6 */ else cout <« "Your ticket price is $50. " << endl; return 0; Exercise 6. (8pts) Add two else-if statements so that children 4 to 12 years old (including 4 and 12) only need to pay $20 for ticket and senior citizens 65 or above only need to pay $30 for ticket. Run your program using the following values as input: 2, 4, 12, 37, 65s, 71. Show the statements you added and the results for the input values in the report. Note: Remove any redundant condition in the logical expressions you wrote for this exercise, otherwise you may only earn partial credit even if the results are correct.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Can anyone help me with these coding questions
4. Nested Logic
Use program TicketPrice for exercises 6-7,
// Program TicketPrice prints the price for a ticket to
// the Wonderland park based on an age input from the keyboard
#include <iostream>
using namespace std;
int main (()
{
int age;
<« "Welcome to Wonderland Park! Please enter your age:"
<« endl;
cout
cin >> age;
if ( age <= 3 )
cout << "Children under 3 can enjoy free admission.
" << endl;
/* TO BE FILLED IN FOR EXERCISE 6 */
else
cout << "Your ticket price is $50. " << endl;
return 0;
}
Exercise 6. (8pts)
Add two else-if statements so that children 4 to 12 years old (including 4 and 12) only need to pay $20
for ticket and senior citizens 65 or above only need to pay $30 for ticket. Run your program using the
following values as input: 2, 4, 12, 37, 65, 71. Show the statements you added and the results for the input
values in the report.
Note: Remove any redundant condition in the logical expressions you wrote for this exercise, otherwise
you may only earn partial credit even if the results are correct.
Exercise 7. (Bonus Problem, 5pts)
Replace the following statement in Exercise 6
cout << "Your ticket price is $50. " <« endl;
with compound statements to check if the guest is eligible for other discounts. Display the following
message:
Are you a student or veteran?
Please enter Y for Yes and N for No.
If the answer is “Y", then display the following message:
You may be eligible for discounted price.
Please show your ID to our staff.
Otherwise (the answer is "N"), display the original message of price $50. Show your compound
statements and the results of a few testing cases.
Transcribed Image Text:4. Nested Logic Use program TicketPrice for exercises 6-7, // Program TicketPrice prints the price for a ticket to // the Wonderland park based on an age input from the keyboard #include <iostream> using namespace std; int main (() { int age; <« "Welcome to Wonderland Park! Please enter your age:" <« endl; cout cin >> age; if ( age <= 3 ) cout << "Children under 3 can enjoy free admission. " << endl; /* TO BE FILLED IN FOR EXERCISE 6 */ else cout << "Your ticket price is $50. " << endl; return 0; } Exercise 6. (8pts) Add two else-if statements so that children 4 to 12 years old (including 4 and 12) only need to pay $20 for ticket and senior citizens 65 or above only need to pay $30 for ticket. Run your program using the following values as input: 2, 4, 12, 37, 65, 71. Show the statements you added and the results for the input values in the report. Note: Remove any redundant condition in the logical expressions you wrote for this exercise, otherwise you may only earn partial credit even if the results are correct. Exercise 7. (Bonus Problem, 5pts) Replace the following statement in Exercise 6 cout << "Your ticket price is $50. " <« endl; with compound statements to check if the guest is eligible for other discounts. Display the following message: Are you a student or veteran? Please enter Y for Yes and N for No. If the answer is “Y", then display the following message: You may be eligible for discounted price. Please show your ID to our staff. Otherwise (the answer is "N"), display the original message of price $50. Show your compound statements and the results of a few testing cases.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education