Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- char username[50];
- char password [50];
- char answerSelection;
- int seat1;
- int seat2;
- int seats;
- int costPrint(int cost);
- void login ();
- void seatSelection();
- void printTicket(int cost, char selection[50], int room, int date);
- int main(int argc, char *argv[]) {
- char selection[50];
- int date;
- int room;
- int verification;
- int cost = 0;
- seat2 = -1;
- login();
- printf("Please select a movie from the following list: \n \n");
- printf("The Avengers \n");
- printf("Suicide Squad \n");
- printf("Inferno \n");
- printf("World War Z \n");
- do
- {
- printf("Type your selection: \n");
- scanf("%s", selection);
- }
- while((strcmp(selection, "The") != 0) && (strcmp(selection, "Suicide") != 0) && (strcmp(selection, "Inferno") != 0) && (strcmp(selection, "World") != 0));
- do
- {
- printf("Please choose the date. Keep in mind that the cinema will be closed after the 24th: \n");
- scanf("%d", &date);
- }
- while((date < 1) || (date > 24));
- room = 1 + rand() % 20;
- printf("Your room is: %d \n", room);
- do
- {
- printf("Please type in the number of your room for verification \n");
- scanf("%d", &verification);
- }
- while(verification != room);
- system("cls");
- int i;
- for(i = 100; i >0; i--)
- {
- if(i >= 80)
- {
- if(i == 80)
- {
- printf("%d \n \n \t", i);
- }
- else
- {
- printf("%d ", i);
- }
- }
- else if(i >= 20)
- {
- if(((i-5)%15 == 0) && (i != 70))
- {
- printf("%d \n \n \t", i);
- }
- else
- {
- if(i == 20)
- {
- printf("%d \n \n \t \t \t", i);
- }
- else
- {
- printf("%d ", i);
- }
- }
- }
- else if(i < 20)
- {
- if(i%10 == 0)
- {
- printf("%d \n \n \t \t", i);
- }
- else
- {
- printf("%d ", i);
- }
- }
- }
- do
- {
- printf(" \n Please choose the number of seats you want to book: \n");
- scanf("%d", &seats);
- }
- while((seats != 1) && (seats !=2));
- seatSelection();
- printf(" \n");
- for(i = 100; i >0; i--)
- {
- if(i == seat1)
- {
- if(seat1 == 80)
- {
- printf(" 0 \n \n \t");
- }
- else if(((seat1 < 80) && (seat1 > 20)) && (seat1 != 70) && ((seat1 -5)%15 == 0))
- {
- printf("0 \n \n \t");
- }
- else if(seat1 == 20)
- {
- printf(" 0 \n \n \t \t");
- }
- else if(seat1 == 10)
- {
- printf(" 0 \n \n \t \t \t");
- }
- else
- {
- printf(" 0 ");
- }
- }
- else if(i == seat2)
- {
- if(seat2 == 80)
- {
- printf(" 0 \n \n \t");
- }
- else if(((seat2 < 80) && (seat2 > 20)) && (seat2 != 70) && ((seat2 -5)%15 == 0))
- {
- printf("0 \n \n \t");
- }
- else if(seat2 == 20)
- {
- printf(" 0 \n \n \t \t");
- }
- else if(seat2 == 10)
- {
- printf(" 0 \n \n \t \t \t");
- }
- else
- {
- printf(" 0 ");
- }
- }
- else if(i >= 80)
- {
- if(i == 80)
- {
- printf("%d \n \n \t", i);
- }
- else
- {
- printf("%d ", i);
- }
- }
- else if((i < 80) && (i > 20))
- {
- if(((i-5)%15 == 0) && (i != 70))
- {
- printf("%d \n \n \t", i);
- }
- else
- {
- printf("%d ", i);
- }
- }
- else if(i == 20)
- {
- printf("%d \n \n \t \t", i);
- }
- else if(i < 20)
- {
- if(i%10 == 0)
- {
- printf("%d \n \n \t \t \t", i);
- }
- else
- {
- printf("%d ", i);
- }
- }
- }
- cost = costPrint(cost);
- printTicket(cost, selection, room, date);
- return 0;
- }
- void login()
- {
- do
- {
- printf("Please enter the username \n");
- scanf("%s", username);
- }
- while(strcmp(username, "movie") != 0);
- do
- {
- printf("Please enter the password \n");
- scanf("%s", password);
- }
- while(strcmp(password, "mo") != 0);
- }
- void seatSelection()
- {
- do
- {
- printf("Please choose the way you want to select your seats \n");
- scanf(" %c", &answerSelection);
- }
- while((answerSelection != 'X') && (answerSelection != 'A'));
- if(answerSelection == 'X')
- {
- do
- {
- printf("Please select your seat: \n");
- scanf("%d", &seat1);
- }
- while((seat1 > 100) && (seat1 < 1));
- if(seats == 2)
- {
- do
- {
- printf("Please select your friend's seat: \n");
- scanf("%d", &seat2);
- }
- while((seat2 > 100) && (seat2 < 1) && (seat2 == seat1) && ((seat2 != seat1 + 1) || (seat2 != seat1 - 1)));
- }
- }
- else
- {
- seat1 = 1 + rand() % 100;
- if(seats == 2)
- {
- do
- {
- seat2 = 1 + rand() % 100;
- }
- while((seat2 > 100) && (seat2 < 1) && (seat2 == seat1) && ((seat2 != seat1 + 1) || (seat2 != seat1 - 1)));
- }
- }
- }
- int costPrint(int cost)
- {
- char card[50];
- if(seats == 1)
- {
- cost = 10;
- }
- else
- {
- cost = 15;
- }
- printf(" \nPlease provide your credit card code: \n");
- scanf("%s", card);
- return cost;
- }
- void printTicket(int cost, char selection[50], int room, int date)
- {
- printf("Here is your e-ticket: \n \n");
- printf("\t ~~~~~~~~~~~~~~~ Demoup Cinemas ~~~~~~~~~~~~~~~ \n \n");
- printf("\t \tTicket No. 1 \n \n ");
- if(strcmp(selection, "The") == 0)
- {
- printf("\t \tMovie: The Avengers \n \n");
- }
- else if(strcmp(selection, "Suicide \n \n") == 0)
- {
- printf("\t \tMovie: Suicide Squad \n \n ");
- }
- else if(strcmp(selection, "World") == 0)
- {
- printf("\t \tMovie: World War Z \n \n ");
- }
- else
- {
- printf("\t \tMovie: Inferno \n \n");
- }
- printf("\t \tDate: %d/12/2016 \t \tRoom: %d \t \tSeat: %d \n \n \n", date, room, seat1);
- printf("\t \t \t Total Cost: %d euro \n \n", cost);
- printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
- if(seats == 2)
- {
- printf("\nHere is your e-ticket: \n \n");
- printf("\t ~~~~~~~~~~~~~~~ Demoup Cinemas ~~~~~~~~~~~~~~~ \n \n");
- printf("\t \tTicket No. 2 \n \n ");
- if(strcmp(selection, "The") == 0)
- {
- printf("\t \tMovie: The Avengers \n \n");
- }
- else if(strcmp(selection, "Suicide \n \n") == 0)
- {
- printf("\t \tMovie: Suicide Squad \n \n ");
- }
- else if(strcmp(selection, "World") == 0)
- {
- printf("\t \tMovie: World War Z \n \n ");
- }
- else
- {
- printf("\t \tMovie: Inferno \n \n");
- }
- printf("\t \tDate: %d/12/2016 \t \tRoom: %d \t \tSeat: %d \n \n \n", date, room, seat2);
- printf("\t \t \t Total Cost: %d euro \n \n", cost);
- printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement