Homework 1 - Ticket Pricing

Please review the rules on collaboration for homework for this course, as well as the guidelines for turning in work.

This assignment is designed to give you practice reading input from the user, using conditional statements to control the program's actions, and printing formatted output. Additionally, you will do some basic testing of user input.

See the "Grading" section below for specific criteria for this assignment. As with all projects and homework, the style guidelines apply to this assignment, and points may be deducted for poor style, readability, and testing.

Learning outcomes

Upon completion of this assignment, students will demonstrate understanding of the following learning outcomes:

1. In the context of low-level, systems programming: 3.Productively develop software within a Unix-style command-line interface (CLI): 8. Author small, memory-safe programs that interact with the world:

Overview

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

Assume the age of the ticket holder will be between 0 and 100 (inclusive). Children 5 and under are free (ticket price should be $0.00 regardless of location). Children between 6 and 10, inclusive, and senior citizens (age 55 and older) receive a $5.00 discount.

Your program needs to prompt the user for the information needed to calcluate the price of a ticket, calculate the price, and then print the result to the screen in a message that confirms the input and states what the resulting ticket price should be. You should format the price of the ticket with a dollar sign before the number, and the number needs to be displayed to two decimal places (just like it appears in the table above).

Input and Output

You may use '0' (zero) and '1' to signal "no" and "yes" when getting input from the user and '1', '2', and '3' when asking what section the purchaser wants.

Remember: you should format the price of the ticket with a dollar sign before the number, and the number needs to be displayed to two decimal places (just like it appears in the table above).

If the user enters a value that is out of bounds, you must print an error message to that effect. For now, you can terminate the program after the error message.

Testing and Error Handling

Be sure when testing to try input that is out of bounds (age > 100, for instance) since the box office is often a very busy place, and users will often make mistakes in typing responses to questions on the screen. Ensure that the program gives useful error messages in those cases.

Since you do not know how to prevent errors such as users entering a letter instead of a number, you do not need to try to catch and handle those errors .... yet. Assume that users will input an integer, although you need to check both positive and negative integer values as well as 0 (zero).

Grading

I highly recommend that for this (and all coding projects) that you make a testing plan before you start to write code. You do not need to plan to test all possible inputs to the program, but you should have a plan that will test major sections of your code and demonstrate your problem solving skills. Include this plan when you submit your code and testing transcript. For this first homework assignment, I am providing you an example testing plan to use for this assignment.

The assignment will be worth 20 points, based on the following criteria: