-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSimple Movie Ticketing System .c
54 lines (42 loc) · 1.42 KB
/
Simple Movie Ticketing System .c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <stdlib.h>
// Define the price per ticket
#define TICKET_PRICE 10
// Function to display available movies
void displayMovies() {
printf("\nAvailable Movies:\n");
printf("1. Movie A\n");
printf("2. Movie B\n");
printf("3. Movie C\n");
printf("4. Movie D\n");
}
int main() {
int choice, numTickets;
double totalCost = 0.0;
printf("Welcome to the Movie Ticket Booking System\n");
while (1) {
// Display available movies
displayMovies();
printf("\nEnter the movie number (1-4) or 0 to exit: ");
scanf("%d", &choice);
if (choice == 0) {
printf("\nThank you for using the Movie Ticket Booking System!\n");
break;
} else if (choice < 1 || choice > 4) {
printf("\nInvalid choice. Please select a valid movie.\n");
continue;
}
printf("Enter the number of tickets: ");
scanf("%d", &numTickets);
if (numTickets < 1) {
printf("\nInvalid number of tickets. Please enter at least 1 ticket.\n");
continue;
}
// Calculate the total cost
totalCost = numTickets * TICKET_PRICE;
printf("\nMovie selected: Movie %c\n", 'A' + choice - 1);
printf("Number of tickets: %d\n", numTickets);
printf("Total cost: $%.2f\n", totalCost);
}
return 0;
}