This is Project 4 in a series of mini exercises for beginners learning C programming. Each project in the series helps you practice essential programming concepts such as variables, conditionals, formatted output, logic flow, and working with external files.
๐ What this project adds to your learning:
- โ
Use of multiple
bool
flags for logic branching - ๐งพ Nested
if
/else
conditionals - ๐งฎ Calculating cumulative percentage-based discounts
- ๐ Reading from an external file using
fopen()
,fgets()
, andfclose()
- ๐จ Displaying styled ASCII art from a
.txt
file
This mini project is a Movie Ticket Discount Tool, designed to simulate a terminal-based ticketing system that calculates and applies discounts based on user input.
When the program is run, it:
- Displays a styled ASCII banner (read from a
.txt
file) - Asks if the user holds a membership card (Y/N)
- Asks the user's age
- Applies relevant discounts depending on age and membership
- Calculates and displays the final ticket price
Two sample runs are shown below:
If youโd like to practice building this project yourself before reviewing the solution, follow these steps:
- Display a custom ASCII banner from a text file using
fopen()
,fgets()
, andfclose()
. - Prompt the user to confirm if they have a membership card (Y/N).
- Ask the user for their age.
- Based on the input:
- ๐ณ Card members: get 10% off
- ๐ถ Students (under 18): get 10% off
- ๐ง Seniors (65+): get 20% off
- ๐ก Multiple discounts can apply (e.g. member + senior = 30% max)
- โ No discount if none of the above apply
- Calculate the final ticket price with a max total discount of 30%.
- Print the result clearly with 2 decimal places.
Note: This project is already complete and includes the full solution. You can explore the code in
main.c
, the ASCII banner insrc/ascii_art.txt
, and the output samples in theimg/
folder.
Happy coding! ๐ฟ๐ฌ