Challenge
No
Mary owns Mighty Mary's Smash Hut, a boxing school in Rochester Hills. She has a special offer, an intro to face smashing course, at a special price. Even cheaper if you have a Groupon. Write a program to compute the price of an order.
Here's some I/O.
- Mighty Mary's Smash Hut
- ====== ====== ===== ===
- Special offer: Face Smashing 101
- How many people (1 to 4)? 2
- Do you have a groupon (Y/N)? n
- Do you want to rent headgear (Y/N)? y
- Do you want to rent body pads (Y/N)?y
- Price: 600
More:
- Mighty Mary's Smash Hut
- ====== ====== ===== ===
- Special offer: Face Smashing 101
- How many people (1 to 4)? 3
- Do you have a groupon (Y/N)? y
- Do you want to rent headgear (Y/N)? n
- Do you want to rent body pads (Y/N)? y
- Price: 387
- You should rent protective gear!
Even more:
- Mighty Mary's Smash Hut
- ====== ====== ===== ===
- Special offer: Face Smashing 101
- How many people (1 to 4)? some
- Sorry, you must enter a whole number.
- How many people (1 to 4)? 3.65
- Sorry, you must enter a whole number.
- How many people (1 to 4)? 4444
- Sorry, please enter a number from 1 to 4.
- How many people (1 to 4)? 3
- Do you have a groupon (Y/N)? not sure
- Please enter Y or N.
- Do you have a groupon (Y/N)? y
- Do you want to rent headgear (Y/N)? maybe
- Please enter Y or N.
- Do you want to rent headgear (Y/N)? y
- Do you want to rent body pads (Y/N)? perhaps
- Please enter Y or N.
- Do you want to rent body pads (Y/N)? n
- Price: 357
- You should rent protective gear!
The price is computed as follows:
- The base price per person is $99 with a Groupon, or $250 without one.
- Headgear rental costs $20 per person, whether or not there is a Groupon.
- Body pads rental cost $30 per person, whether or not there is a Groupon.
For all input, keep asking until the user enters valid values.
- People count must be an int from 1 to 4.
- Other inputs should be y or n. Strip spaces, and allow upper- and lowercase.
If the user says they don't want headgear and/or body pads (either or both), show a warning after the price.
Write a reusable function to get one Y/N input at a time. Call it three times.
Upload a zip of your project folder. The usual coding standards apply.
If you were logged in as a student, you could submit a solution to this exercise.
Where referenced