Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function ticket price(), which takes three arguments, in the following order: base price: an integer that gives the base (regular) price of a

Write a function ticket price(), which takes three arguments, in the following order:

base price: an integer that gives the base (regular) price of a train ticket

membership: a string that indicates the travel membership class of a train passenger: platinum, gold, silver or bronze

age: an integer that indicates a train passengers age

The function uses these three values to compute and return the final ticket price that a particular train passenger must pay, based on his/her membership class and age. Unfortunately, we dont have a nice, neat explanation of how to use these three values. All we have to go by is the following hastily written email from the train companys marketing department:

Sorry for the rush on this, but we need this program working ASAP. Right, so, platinum members and younger passengers (less than 65 years old) have to pay a $6 premium on the regular ticket price. Yeah, doesnt seem fair, but thats what management wants. No, it doesnt matter what membership the younger passengers are in just slap on the $6 charge. Gold and silver members always pay a $4 premium. Now, I know what youre thinking but what about the less than 65 years old rule? First check if the traveler is less than 65 and if so, hit them with that $6 charge. Only if the passenger is 65 or older AND a gold or silver member should you assess the $4 charge. Sorry if this is confusing. Now, older bronze members (older means 65 or older) pay a $2 premium; younger bronze members will have to pay that $6 premium I told you about earlier because theyre younger members (so the bronze status is actually irrelevant here). Hope this makes sense talk to your supervisor if you have questions.image text in transcribed

Examples: Return Value Function Arguments 100, 'platinum', 77 106 100, 'platinum, 21106 100, gold, 25 50, 'gold', 71 60,'silver', 67 90, 'bronze', 67 60, bronze, 45 106 54 64 92

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

Students also viewed these Databases questions