You’ve been asked by a local community theater to write a small program to calculate the price of a ticket for the box office staff. The problem is that the price of a ticket depends upon several factors:
The price schedule for tickets is:
| Location | Matinee | Evening |
|---|---|---|
| Main floor - middle section | $25.00 | $30.00 |
| Main floor - sides | $20.00 | $25.00 |
| Balcony | $15.00 | $20.00 |
Valid ages for ticket holders are between 0 and 150 (inclusive). Tickets for children 5 and under are free regardless of time and location. Children between 6 and 10, inclusive, and senior citizens (age 55 and older) receive a \$5.00 discount.
Your program should implement the following behaviors:
All prices should be printed with a dollar sign before the number, using two decimal places just as the numbers in the table above.
When you present users with a choice of several options, print them with numbers and ask them to type the number corresponding to the option they want. We will explore alternative ways to collect input from users later in the semester.
Your program must check the validity of all inputs; an age that is less than zero or greater than 150 should be rejected, as should any attempt to select an option that does not exist. When a user provides an invalid input, print a message to report that the input was invalid (include an explanation of why) and ask them to try again. We haven’t yet looked at how we can read non-numeric data, so you may assume users will always type a number when you ask them to. Just don’t assume the number will be acceptable without checking it first.
You will submit your work for this homework assignment on gradescope.
Please upload your implementation in a file named boxoffice.c, along with a testing transcript.
You can create a testing transcript by running:
$ script tests.txt
The command above will record the commands you run and any outputs to a file named tests.txt.
Run the program as many times as you need to thoroughly test your implementation, then run exit to end the transcript.
Include tests.txt with your implementation when you submit your work to gradescope.
You should make sure your testing covers at least the following cases:
It is in your interest to be thorough with your testing. Your tests must cover these cases to receive credit for the testing portion of your grade, but testing your code will help you find bugs that might otherwise have hurt your score in other parts of the assignment.
Your assignment will be graded on a scale of 0–100 points based on the following criteria:
There will be potential deductions for any code quality violations. For now, there are six requirements for quality code:
if–else block that explains what the purpose of that code is. The comment should not simply restate the code; it should add information for a human who reads the code and is confused.