0% found this document useful (0 votes)
4 views9 pages

Import Java

The document is a Java program for a movie ticket booking system that allows users to book tickets, view bookings, and exit the application. It manages three types of seats (Silver, Gold, Platinum) with predefined availability and prices, and records booking details in a text file. The program uses a simple menu-driven interface for user interaction.

Uploaded by

pujitasps
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views9 pages

Import Java

The document is a Java program for a movie ticket booking system that allows users to book tickets, view bookings, and exit the application. It manages three types of seats (Silver, Gold, Platinum) with predefined availability and prices, and records booking details in a text file. The program uses a simple menu-driven interface for user interaction.

Uploaded by

pujitasps
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import [Link].

*;

import [Link].*;

class MovieTicketBooking

static int silverSeats = 50;

static int goldSeats = 40;

static int platinumSeats = 30;

public static void main(String args[]) throws IOException

Scanner sc = new Scanner([Link]);

int choice;

do

[Link]("\n===== MOVIE TICKET BOOKING SYSTEM =====");

[Link]("1. Book Ticket");

[Link]("2. View Bookings");

[Link]("3. Exit");

[Link]("Enter your choice: ");

choice = [Link]();

[Link]();

switch(choice)

case 1:

bookTicket(sc);
break;

case 2:

viewBookings();

break;

case 3:

[Link]("Thank you for using the system!");

break;

default:

[Link]("Invalid Choice!");

} while(choice != 3);

static void bookTicket(Scanner sc) throws IOException

FileWriter fw = new FileWriter("[Link]", true);

[Link]("\nAvailable Movies:");

[Link]("1. Avatar");

[Link]("2. Avengers");

[Link]("3. Inception");

[Link]("Choose Movie (1-3): ");

int m = [Link]();
[Link]();

String movie = "";

if(m == 1) movie = "Avatar";

else if(m == 2) movie = "Avengers";

else if(m == 3) movie = "Inception";

else

[Link]("Invalid Movie Choice!");

return;

[Link]("Enter Date (dd/mm/yyyy): ");

String date = [Link]();

[Link]("Enter Show Time: ");

String time = [Link]();

[Link]("\nSeat Availability:");

[Link]("Silver: " + silverSeats);

[Link]("Gold: " + goldSeats);

[Link]("Platinum: " + platinumSeats);

[Link]("Enter Seat Type (Silver/Gold/Platinum): ");

String seat = [Link]();

[Link]("Enter Number of Tickets: ");

int tickets = [Link]();


int price = 0;

if([Link]("Silver") && tickets <= silverSeats)

price = 150;

silverSeats -= tickets;

else if([Link]("Gold") && tickets <= goldSeats)

price = 250;

goldSeats -= tickets;

else if([Link]("Platinum") && tickets <= platinumSeats)

price = 400;

platinumSeats -= tickets;

else

[Link]("Seats not available!");

return;

int total = price * tickets;

[Link]("Movie Name: " + movie + "\n");

[Link]("Date: " + date + "\n");


[Link]("Show Time: " + time + "\n");

[Link]("Seat Type: " + seat + "\n");

[Link]("Tickets Booked: " + tickets + "\n");

[Link]("Total Amount: Rs. " + total + "\n");

[Link]("-----------------------------------\n");

[Link]();

[Link]("\nBooking Successful!");

[Link]("Total Amount: Rs. " + total);

static void viewBookings() throws IOException

File file = new File("[Link]");

if(![Link]())

[Link]("No bookings found!");

return;

BufferedReader br = new BufferedReader(new FileReader(file));

String line;

[Link]("\n----- BOOKING DETAILS -----");

while((line = [Link]()) != null)


{

[Link](line);

[Link]();

You might also like