Tutorial Week 8 - Subroutines


Home


Question 1

Modify question 2 from Lab week 7 (totalling marks) so that it uses a subroutine to input and validate a mark input by the user.

Question 2

The price of tickets to a concert depends on the age of the customer. If the customer is a child (under 16 years) a ticket costs $50 otherwise a ticket costs $70 for adults. Write a program that asks the user the type of ticket required, then prints (displays) a ticket. Tickets are numbered commencing at 1001. Use subroutines when writing your solution.

Run

Type (C=Child, A=Adult, X = Exit) ? A
--------------------
Ticket Number 1001
Admits 1 Adult
Price $70.00
--------------------

Type (C=Child, A=Adult, X = Exit) ? C
--------------------
Ticket Number 1002
Admits 1 Child
Price $50.00
--------------------
Type (C=Child, A=Adult, X = Exit) ? C
--------------------
Ticket Number 1003
Admits 1 Child
Price $50.00
--------------------
Type (C=Child, A=Adult, X = Exit) ? X

Written by Tim Whitfort.