0% found this document useful (0 votes)
19 views2 pages

Java Console Ticket Booking System

The document describes a project for a console-based ticket booking system implemented in Java, which manages a fixed number of seats and allows users to book tickets until sold out. It highlights the use of Java's Scanner for input, control flow with loops and conditionals, and state management through class variables. The project successfully demonstrates key Java concepts and provides a user-friendly interface for booking tickets.

Uploaded by

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

Java Console Ticket Booking System

The document describes a project for a console-based ticket booking system implemented in Java, which manages a fixed number of seats and allows users to book tickets until sold out. It highlights the use of Java's Scanner for input, control flow with loops and conditionals, and state management through class variables. The project successfully demonstrates key Java concepts and provides a user-friendly interface for booking tickets.

Uploaded by

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

Project Title

Ticket Booking System in Java

1. Introduction
This project implements a simple console-based ticket booking system. It simulates the
management of a fixed number of seats (initially 10) and allows users to book tickets until the
seats are sold out. Users can exit the program by entering 0. It demonstrates basic Java concepts
such as loops, conditionals, user input handling, and variable manipulation.

2. Objectives

 Demonstrate the use of Java’s Scanner for console input.


 Showcase control flow using while, if–else statements.
 Manage state using class variables (seats).
 Develop a user-friendly loop for booking until seats are depleted or the user opts out.

3. Program Code

java
CopyEdit
import [Link].*;

public class TicketBooking {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
int seats = 10;

while (true) {
[Link]("\nAvailable Seats: " + seats);
[Link]("Enter number of tickets to book (0 to exit): ");
int num = [Link]();

if (num == 0) {
[Link]("Thank you for using Ticket Booking!");
break;
} else if (num <= seats) {
seats -= num;
[Link]("Booked " + num + " ticket(s). Remaining: "
+ seats);
} else {
[Link]("Not enough seats. Try less.");
}
}
[Link]();
}
}

4. Output

vbnet
CopyEdit
Available Seats: 10
Enter number of tickets to book (0 to exit): 3
Booked 3 ticket(s). Remaining: 7

Available Seats: 7
Enter number of tickets to book (0 to exit): 0
Thank you for using Ticket Booking!

=== Code Execution Successful ===

5. Conclusion
This project successfully implements a basic ticket booking system with console interaction. It
effectively demonstrates key Java fundamentals:

 Handling user input through Scanner.


 Using loops and conditionals for decision-making.
 Managing and updating program state.

You might also like