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

Metro Train Ticket Booking System

It is the java program with all detail for metro Train ticket booking

Uploaded by

smrithun2008
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 views18 pages

Metro Train Ticket Booking System

It is the java program with all detail for metro Train ticket booking

Uploaded by

smrithun2008
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

Metro Train Ticket Booking

Introduction:
Java is a versatile, object-oriented programming
language designed for building robust, high-performance
applications. Originally developed by Sun Microsystems and
released in 1995, Java is known for its "write once, run anywhere"
capability, thanks to the Java Virtual Machine (JVM) that allows
code to run on any platform without modification. It supports a rich
set of libraries and frameworks, making it suitable for a wide range
of applications, from web and mobile apps to large-scale enterprise
systems. Java's emphasis on portability, security, and scalability

has made it a popular choice among developers worldwide.

Java continues to evolve, with recent updates focusing


on enhancing developer productivity, performance, and modern
application development. Java 21, the latest long-term support (LTS)
release, introduces new features like pattern matching for switch
expressions, record patterns, and virtual threads. These additions
simplify code, making it more readable and efficient, especially in
multi-threaded environments.

Java's ecosystem is also expanding into cloud-native and


microservices architectures, with frameworks like Spring Boot and
Quarkus enabling developers to build scalable, high-performance
applications quickly. Additionally, Project Loom, still under
development, promises to revolutionize concurrency in Java by
making lightweight, efficient virtual threads a core part of the
language, allowing for more scalable applications with less
complexity.

About the Program:


The Metro Ticket Booking program is a
Java-based console application designed to simulate the process of
booking metro train tickets between various stations. Through a
simple, interactive menu-driven interface, users can choose from
four different routes, each offering multiple destinations. The
program calculates ticket prices based on the chosen destination
and quantity of tickets, and allows for continuous bookings before
generating the final bill. It’s a practical example of how basic
programming concepts such as loops, conditional statements, and
user input handling can be used to develop a functional ticket
booking system.

Program:

import [Link].*;

public class Metro_Ticket_Booking

{
public static void main(String args[])

Scanner in = new Scanner([Link]);

int ch, centowim, tcentowim, amt = 0, tamt = 0,


wimtocen, twimtocen, tamt1 = 0, centost, tcentost, tamt2 = 0,
tamt3=0,sttocen,tsttocen,total;

String choice1 = "Y";

[Link]("Welcome to Metro Ticket


Booking");

[Link]("1. Train Ticket Booking Route from


M.G.R Central Metro to Wimco Nagar Metro");

[Link]("2. Train Ticket Booking Route from


Wimco Nagar Metro to M.G.R Central Metro");

[Link]("3. Train Ticket Booking Route from


M.G.R Central Metro to [Link] Mount Metro");

[Link]("4. Train Ticket Booking Route from


[Link] Mount Metro to M.G.R Central Metro");

[Link]("");

while ([Link]("Y"))

{
[Link]("Enter Your Choice:");

ch = [Link]();

switch (ch)

case 1:

[Link]("Welcome to M.G.R Central


Metro Ticket Counter ");

[Link]("Destination
Price in Rs.");

[Link]("[Link] Court Rs
10");

[Link]("[Link]
Rs 20");

[Link]("[Link]
Rs 20");

[Link]("[Link] College
Rs 30");

[Link]("[Link]
Rs 30");

[Link]("[Link] Washermen Pet


Rs 30");
[Link]("[Link] Gate
Rs 30");

[Link]("[Link]
Rs 30");

[Link]("[Link]
Rs 30");

[Link]("[Link] Nagar
Rs 40");

[Link]("");

String choice = "Y";

while ([Link]("Y"))

[Link]("Choose The Destination


by Entering the Number ");

centowim = [Link]();

[Link]("Enter The Quantity: ");

tcentowim = [Link]();

if (centowim == 1)

amt = tcentowim * 10;

else if (centowim == 2 || centowim == 3)

amt = tcentowim * 20;


else if (centowim >= 4 && centowim <= 9)

amt = tcentowim * 30;

else if (centowim == 10)

amt = tcentowim * 40;

tamt += amt;

[Link]("Do You Want to Book


More Ticket ? Enter Y/N");

choice = [Link]();

break;

case 2:

[Link]("Welcome to Wimco Nagar


Metro Ticket Counter ");

[Link]("Destination
Price in Rs.");

[Link]("[Link] Metro
Rs 40");

[Link]("[Link] Court Rs
30");
[Link]("[Link]
Rs 30");

[Link]("[Link]
Rs 30");

[Link]("[Link] College
Rs 30");

[Link]("[Link]
Rs 30");

[Link]("[Link] Washermen Pet


Rs 30");

[Link]("[Link] Gate
Rs 20");

[Link]("[Link]
Rs 20");

[Link]("[Link]
Rs 10");

[Link]("");

choice = "Y";

while ([Link]("Y"))

[Link]("Choose the Destination by


Entering The Number : ");
wimtocen = [Link]();

[Link]("Enter the Quantity:");

twimtocen = [Link]();

if (wimtocen == 1)

amt = twimtocen * 40;

else if (wimtocen >= 2 && wimtocen <= 7)

amt = twimtocen * 30;

else if (wimtocen == 8 || wimtocen == 9)

amt = twimtocen * 20;

else if (wimtocen == 10)

amt = twimtocen * 10;

tamt1 += amt;

[Link]("Do You Want to Book


More Ticket ? Enter Y/N");

choice = [Link]();

break;

case 3:

[Link]("Welcome To M.G.R Central


Ticket Counter ");
[Link]("Destination
Price in Rs.");

[Link]("[Link] Metro
10 ");

[Link]("[Link] Park Metro


20 ");

[Link]("[Link] Metro
20 ");

[Link]("[Link]'s College
Metro 20 ");

[Link]("[Link] Nagar
30 ");

[Link]("[Link] Nagar East Metro


30 ");

[Link]("[Link] Nagar Tower Metro


30 ");

[Link]("[Link] Metro
30 ");

[Link]("[Link] Metro
30 ");

[Link]("[Link] CMBT Metro


30 ");
[Link]("[Link] Metro
40 ");

[Link]("[Link] Metro
40 ");

[Link]("[Link] Nagar Metro


40 ");

[Link]("[Link] Metro
40 ");

[Link]("[Link] Anna Alandur


Metro 40 ");

[Link]("[Link] Mount Metro


40 ");

[Link]("");

choice = "Y";

while ([Link]("Y"))

[Link]("Choose the Destination by


entering Number:");

centost = [Link]();

[Link]("Enter the Quantity");

tcentost = [Link]();

if (centost == 1)
amt = tcentost * 10;

else if (centost >= 2 && centost <= 4)

amt = tcentost * 20;

else if (centost >= 5 && centost <= 10)

amt = tcentost * 30;

else if (centost >= 11 && centost <= 16)

amt = tcentost * 40;

tamt2 += amt;

[Link]("Do You Want To Place


More Order? Enter Y/N");

choice = [Link]();

break;

case 4:

[Link]("Welcome To [Link]
Mount Metro Ticket Counter ");

[Link]("Destination
Price in Rs.");

[Link]("1.M.G.R Central Metro


40 ");
[Link]("[Link] Metro
40 ");

[Link]("[Link] Park Metro


40 ");

[Link]("[Link] Metro
40 ");

[Link]("[Link]'s College
Metro 40 ");

[Link]("[Link] Nagar
40 ");

[Link]("[Link] Nagar East Metro


40 ");

[Link]("[Link] Nagar Tower Metro


40 ");

[Link]("[Link] Metro
40 ");

[Link]("[Link] Metro
30 ");

[Link]("[Link] CMBT Metro


30 ");

[Link]("[Link] Metro
30 ");
[Link]("[Link] Metro
30 ");

[Link]("[Link] Nagar Metro


20 ");

[Link]("[Link] Metro
20 ");

[Link]("[Link] Anna Alandur


Metro 10 ");

[Link]("");

choice = "Y";

while ([Link]("Y"))

[Link]("Choose the Destination by


entering Number:");

sttocen = [Link]();

[Link]("Enter the Quantity");

tsttocen = [Link]();

if (sttocen == 1)

amt = tsttocen * 10;

else if (sttocen >= 2 && sttocen <= 4)

amt = tsttocen * 20;


else if (sttocen >= 5 && sttocen <= 10)

amt = tsttocen * 30;

else if (sttocen >= 11 && sttocen <= 16)

amt = tsttocen * 40;

tamt3 += amt;

[Link]("Do You Want To Place


More Order? Enter Y/N");

choice = [Link]();

break;

default:

[Link]("Choice is Wrong");

break;

[Link]("Enter Y to go to Main Menu and N


to Print the Bill:");

choice1 = [Link]();

[Link]("Metro Ticket Booking");


[Link]("Central To Wimco Nagar");

[Link]("Cost for Central To Wimco Nagar=


Rs." + tamt);

[Link]("Wimco Nagar To Central");

[Link]("Cost From Wimco Nagar To


Central= Rs." + tamt1);

[Link]("Central To [Link]");

[Link]("Cost From Central To [Link]=


Rs." + tamt2);

[Link]("[Link] To Central");

[Link]("Coast From [Link] To Central=


Rs." + tamt3);

total = tamt + tamt1 + tamt2 + tamt3;

[Link]("Total Amount To Be Paid = Rs." +


total);

Output:

You might also like