Question

i need a movie ticket booking source code in C++

i need a movie ticket booking source code in C++
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The code:


#include<stdio.h>
#include<stdlib.h>

/* Creating a structure*/
struct book
{
   char code[20];
   char name[20];
   char date[20];
   int cost;
  

}b;

void login()
{ char user[10];
char pass[10];
   int a=0,i=0;
char uname[10],c=' ';
char pword[10],code[10];
  
do
{
  
printf("\n //////////////////////// LOGIN FIRST \\\\\\\\\\\\\\\\\\\\\\\\\\ ");
printf(" \n\n Put valid username:-");
   scanf("%s", &uname);
   printf(" \n\n Put valid password:-");
   while(i<10)
   {
   pword[i]=getch();
   c=pword[i];
   if(c==13) break;
   else printf("*");
   i++;
   }
   pword[i]='\0';
   //char code=pword;
   i=0;
   //scanf("%s",&pword);
       if(strcmp(uname,"HomeworkLib")==0 && strcmp(pword,"student")==0)
   {
   printf(" \n\n\n Welcome to our booking system ! Your login is sucessful");
   printf("\n\n\n\t\t\t\tPress any key to continue...");
   getch();//holds the screen
   break;
   }
   else
   {
       printf("\n Sorry your login is unsucessful");
       a++;
      
       getch();//holds the screen
      
   }
}
   while(a<=2);
   if (a>2)
   {
       printf("\nSorry you have entered the wrong username and password for four times!!!");
      
       getch();
      
       }
       system("cls");
      
}


int seat = 60 ;

void insert_details();//for inserting movie details
void viewAll(); // for view all data
void find(); // for finding data
void book_ticket(); //for booking tickets
void old_record(); //for view old recorrds of users,booked tickets

void main()
{
login();
   int ch;
    do{
   printf("\n/////////////////////////////////////////////////////////////////////");
   printf("\n");  
   printf("\t Moive Ticket booking ");
   printf("\n");
   printf("\n/////////////////////////////////////////////////////////////////////");
  
   printf("\nEnter >1< To Insert Movie");
    printf("\nEnter >2< To View All Movie");
   printf("\nEnter >3< To Find Movie ");
   printf("\nEnter >4< To Book Tickets");
   printf("\nEnter >5< To View All Transactions");
    printf("\nEnter >0< To Exit ");

    printf("\nEnter your Choice ::");
    scanf("%d",&ch);
   system("cls");  

    switch (ch)
    {
       case 1 :
       insert_details();
        break;
       case 2:
       viewAll();
        break;
      
       case 3:
       find();
        break;

       case 4:
       book_ticket();
       break;
      
       case 5:
       old_record();
       break;

       case 0:
       exit(0);
       break;

       default:
       printf("Wrong choice !");
       break;
    }
}while(ch!=0);

  


}


void insert_details()
{
  
   FILE *fp;
   struct book b;
   printf("Enter movie code :- ");  
   scanf("%s",b.code);
   printf("Enter name :- ");  
   scanf("%s",b.name);
   printf("Enter Release Date:- ");  
   scanf("%s",b.date);
   printf("Enetr Ticket Price:- ");  
   scanf("%d",&b.cost);
  
   fp=fopen("data.txt","a");

   if(fp == NULL)
   {
       printf("FIle not Found");
   }
   else
   {
       fprintf(fp,"%s %s %s %d \n",b.code,b.name,b.date,b.cost);
       printf("Recorded Successfully");
   }
       printf("\n");
   fclose(fp);
   system("cls");
}
void find() //find details
{
   struct book b;
   FILE *fp;
  
   char ch[20];
   printf("Enter movie code :");
   scanf("%s",ch);

   fp = fopen("data.txt","r");
   if(fp == NULL)
   {
       printf("file does not found !");
       exit(1);

   }
   else
   {  
       while(getc(fp) != EOF)
       {
           fscanf(fp,"%s %s %s %d",b.code,b.name,b.date,&b.cost);
           if(strcmp(b.code,ch) == 0)
           {  
               //printf("%s / %s / %s / %d\n",b.code,b.name,b.date,b.cost);
               printf("\n Record Found\n");
               printf("\n\t\tCode ::%s",b.code);
               printf("\n\t\tmovie name ::%s",b.name);
               printf("\n\t\tmovie date ::%s",b.date);
               printf("\n\t\tprice of ticket ::%d",b.cost);
           }
       }
      
   }

   fclose(fp);
   system("cls");
}
void viewAll()
{
  
   char ch;
   FILE *fp;

   fp = fopen("data.txt","r");
   if(fp == NULL)
   {
       printf("file does not found !");
       exit(1);

   }
   else
   {  
       system("cls");
       while( ( ch = fgetc(fp) ) != EOF )
       printf("%c",ch);
      
   }
  
   fclose(fp);

}
//for ticket booking
void book_ticket()
{
struct book b;
   FILE *fp;

   FILE *ufp;

   int total_seat,mobile,total_amount;
   char name[20];

  
   char ch; //used in display all movies
   char movie_code[20]; //for searching

   // disply all moives by default for movie code
   fp = fopen("data.txt","r");
   if(fp == NULL)
   {
       printf("file does not found !");
       exit(1);

   }
   else
   {  
       system("cls");
       while( ( ch = fgetc(fp) ) != EOF )
       printf("%c",ch);
      
   }
   fclose(fp);
  
   //display ends
   printf("\n For Book ticket Choice Movie(Enter Movie Code First Latter Of Movie)\n");
   printf("\n Enter movie code :");
   scanf("%s",movie_code);
   //system("clear");
   fp = fopen("data.txt","r");
   if(fp == NULL)
   {
       printf("file does not found !");
       exit(1);

   }
   else
   {  
       while(getc(fp) != EOF)
       {
           fscanf(fp,"%s %s %s %d",b.code,b.name,b.date,&b.cost);
           if(strcmp(b.code,movie_code) == 0)
           {  
               //printf("%s / %s / %s / %d\n",b.code,b.name,b.date,b.cost);
               printf("\n Record Found\n");
               printf("\n\t\tCode ::%s",b.code);
               printf("\n\t\tMovie name ::%s",b.name);
               printf("\n\t\tdate name ::%s",b.date);
               printf("\n\t\tPrice of ticket::%d",b.cost);
           }
       }
      
   }
   printf("\n* Fill Deatails *");
   printf("\n your name :");
   scanf("%s",name);
   printf("\n mobile number :");
   scanf("%d",&mobile);
   printf("\n Total number of tickets :");
   scanf("%d",&total_seat);
  
  
   total_amount = b.cost * total_seat;
  
   printf("\n ENJOY MOVIE \n");
   printf("\n\t\tname : %s",name);
   printf("\n\t\tmobile Number : %d",mobile);
   printf("\n\t\tmovie name : %s",b.name);
   printf("\n\t\tTotal seats : %d",total_seat);
   printf("\n\t\tcost per ticket : %d",b.cost);
   printf("\n\t\tTotal Amount : %d",total_amount);
  
  
   ufp=fopen("oldTransection.txt","a");
   if(ufp == NULL)
   {
       printf("FIle not Found");
   }
   else
   {
       fprintf(ufp,"%s %d %d %d %s %d \n",name,mobile,total_seat,total_amount,b.name,b.cost);
       printf("\n Record insert Sucessfull to the old record file");
   }
       printf("\n");
   fclose(ufp);
   fclose(fp);

}
//for view all user transections
void old_record()
{
   char ch;
   FILE *fp;

   //system("clear");
  
   fp = fopen("oldTransection.txt","r");
   if(fp == NULL)
   {
       printf("file does not found !");
       exit(1);

   }
   else
   {  
       system("cls");
       while( ( ch = fgetc(fp) ) != EOF )
       printf("%c",ch);
      
   }
   fclose(fp);


}

You need to create data.txt file where you store the names of movies and also the transaction text file add in transaction you want to show

Add a comment
Know the answer?
Add Answer to:
i need a movie ticket booking source code in C++
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • need help with c++ project: For the project. Create a c++ program about bus booking and...

    need help with c++ project: For the project. Create a c++ program about bus booking and ticketing system that - This system also needs you to key in your username and password precisely and ask again to confirm your booking of the bus ticket, and output of the ticket fully displayed -Must include selections, looping and functions, and array. - minimum of 6 functions including main function Keywords that should not be in the source code: class, struct, fstream, ifstream,...

  • (1) The Movie, Ticket, Theatre and Patron Classes You will need to define 4 objects as...

    (1) The Movie, Ticket, Theatre and Patron Classes You will need to define 4 objects as indicated below. You must choose appropriate attribute names so that the test program that follows compiles and runs properly. Define a class called Movie that maintains the title of a movie as well as the amount of earnings it has made since it opened at the theatre . Define a class called Theatre that keeps track of the Movie object that is currently playing...

  • (1) The Movie, Ticket, Theatre and Patron Classes You will need to define 4 objects as...

    (1) The Movie, Ticket, Theatre and Patron Classes You will need to define 4 objects as indicated below. You must choose appropriate attribute names so that the test program that follows compiles and runs properly Define a class called Movie that maintains the title of a movie as well as the amount of earnings it has made since it opened at the theatre Define a class called Theatre that keeps track of the Movie object that is currently playing in...

  • I have this java program that I need to add an abstract method and polymorphism to...

    I have this java program that I need to add an abstract method and polymorphism to it : import java.util.Scanner; //class and encapsulation class BookTheTicket { private String movieName; private String theatreName; private int ticketCost; void myAllmovies() { System.out.println("-------Listing the movies:------"); System.out.println(" 1.DDLJ ------------ $40 \n 2.kkr---------$.50 \n 3.game-movie --------$60 \n 4.fun movie ----- $.70 "); } } // inheritence class theater extends BookTheTicket{ private int numOfTickets; void theater() { System.out.println("*******Listing the theatre:******* \n 1.coco cola tld \n 2.koi gandhi...

  • NOTE: I ONLY NEED THE CODE FOR THIS PART: "3 - add movie and category to...

    NOTE: I ONLY NEED THE CODE FOR THIS PART: "3 - add movie and category to list for an entered year". YOU DON'T HAVE TO GIVE ME THE CODE FOR MENU OPTIONS 1, 2, pc, p, OR q BECAUSE I HAVE THAT ALREADY. ONLY 3! EDIT: THIS IS FOR PYTHON 3.8. In this assignment you are to enhance the movie list display program from Assignment 4 to help maintain a list of movies that won the Academy Award (Oscar) for...

  • This I need the source code and design for the form. Please complete this in Visual...

    This I need the source code and design for the form. Please complete this in Visual Basic .NET

  • Suppose you pre-ordered a non-refundable movie ticket to Avengers: Infinity War. On the day of the...

    Suppose you pre-ordered a non-refundable movie ticket to Avengers: Infinity War. On the day of the movie you decide that you would rather not go to the movie. According to economists, what is the rational thing to do? Since you do not want to go to the movie and the cost of the movie ticket is a sunk cost, how much you paid for the ticket should not influence your decision. You should go to the movie to minimize your...

  • The probability of buying a movie ticket with a popcorn coupon is 0.608. If you buy...

    The probability of buying a movie ticket with a popcorn coupon is 0.608. If you buy 10 movie tickets, what is the probability that 3 or more of the tickets have popcorn coupons? (Round your answer to 3 decimal places if necessary.) Seen multiple "correct" answers for this. Utilizing the calculator on my exam I received .951. The exam shows it as .999 with some crazy by hand method. We were taught to use the calculator functions. Trying to see...

  • The probability of buying a movie ticket with a popcorn coupon is 0.608. If you buy...

    The probability of buying a movie ticket with a popcorn coupon is 0.608. If you buy 10 movie tickets, what is the probability that 3 or more of the tickets have popcorn coupons? (Round your answer to 3 decimal places if necessary.)

  • A movie theater wanted to determine what factors might be influencing their ticket sales. They decided...

    A movie theater wanted to determine what factors might be influencing their ticket sales. They decided to conduct a multiple linear regression with 4 predictor variables. They took a sample size of 27 weeks. Using the ANOVA table below find the degrees of freedom for error. Round to 2 decimal places as necessary. source df sum of squares mean square f ratio model 16.1 2.76 error 208.8 13.12 total

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT