0% found this document useful (0 votes)
6 views

Computer Project

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

Uploaded by

smrithun2008
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Computer Project

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

Uploaded by

smrithun2008
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

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 java.util.*;

public class Metro_Ticket_Booking

{
public static void main(String args[])

Scanner in = new Scanner(System.in);

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


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

String choice1 = "Y";

System.out.println("Welcome to Metro Ticket


Booking");

System.out.println("1. Train Ticket Booking Route from


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

System.out.println("2. Train Ticket Booking Route from


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

System.out.println("3. Train Ticket Booking Route from


M.G.R Central Metro to St.Thomas Mount Metro");

System.out.println("4. Train Ticket Booking Route from


St.Thomas Mount Metro to M.G.R Central Metro");

System.out.println("");

while (choice1.equalsIgnoreCase("Y"))

{
System.out.println("Enter Your Choice:");

ch = in.nextInt();

switch (ch)

case 1:

System.out.println("Welcome to M.G.R Central


Metro Ticket Counter ");

System.out.println("Destination
Price in Rs.");

System.out.println("1.High Court Rs
10");

System.out.println("2.Mannady
Rs 20");

System.out.println("3.Washermenpet
Rs 20");

System.out.println("4.Theagaraya College
Rs 30");

System.out.println("5.Tondiarpet
Rs 30");

System.out.println("6.New Washermen Pet


Rs 30");
System.out.println("7.Toll Gate
Rs 30");

System.out.println("8.Kaladipet
Rs 30");

System.out.println("9.Thiruvotriyur
Rs 30");

System.out.println("10.Wimco Nagar
Rs 40");

System.out.println("");

String choice = "Y";

while (choice.equalsIgnoreCase("Y"))

System.out.println("Choose The Destination


by Entering the Number ");

centowim = in.nextInt();

System.out.println("Enter The Quantity: ");

tcentowim = in.nextInt();

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;

System.out.println("Do You Want to Book


More Ticket ? Enter Y/N");

choice = in.next();

break;

case 2:

System.out.println("Welcome to Wimco Nagar


Metro Ticket Counter ");

System.out.println("Destination
Price in Rs.");

System.out.println("1.Central Metro
Rs 40");

System.out.println("2.High Court Rs
30");
System.out.println("3.Mannady
Rs 30");

System.out.println("4.Washermenpet
Rs 30");

System.out.println("5.Theagaraya College
Rs 30");

System.out.println("6.Tondiarpet
Rs 30");

System.out.println("7.New Washermen Pet


Rs 30");

System.out.println("8.Toll Gate
Rs 20");

System.out.println("9.Kaladipet
Rs 20");

System.out.println("10.Thiruvotriyur
Rs 10");

System.out.println("");

choice = "Y";

while (choice.equalsIgnoreCase("Y"))

System.out.println("Choose the Destination by


Entering The Number : ");
wimtocen = in.nextInt();

System.out.println("Enter the Quantity:");

twimtocen = in.nextInt();

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;

System.out.println("Do You Want to Book


More Ticket ? Enter Y/N");

choice = in.next();

break;

case 3:

System.out.println("Welcome To M.G.R Central


Ticket Counter ");
System.out.println("Destination
Price in Rs.");

System.out.println("1.Egmore Metro
10 ");

System.out.println("2.Nehru Park Metro


20 ");

System.out.println("3.Kilpak Metro
20 ");

System.out.println("4.Pachaiyappa's College
Metro 20 ");

System.out.println("5.Shenoy Nagar
30 ");

System.out.println("6.Anna Nagar East Metro


30 ");

System.out.println("7.Anna Nagar Tower Metro


30 ");

System.out.println("8.Thirumangalam Metro
30 ");

System.out.println("9.Koyambedu Metro
30 ");

System.out.println("10.Jayalalithaa CMBT Metro


30 ");
System.out.println("11.Arumbakkam Metro
40 ");

System.out.println("12.Vadapalani Metro
40 ");

System.out.println("13.Ashok Nagar Metro


40 ");

System.out.println("14.Ekkattuthangal Metro
40 ");

System.out.println("15.Aringar Anna Alandur


Metro 40 ");

System.out.println("16.St.Thomas Mount Metro


40 ");

System.out.println("");

choice = "Y";

while (choice.equalsIgnoreCase("Y"))

System.out.println("Choose the Destination by


entering Number:");

centost = in.nextInt();

System.out.println("Enter the Quantity");

tcentost = in.nextInt();

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;

System.out.println("Do You Want To Place


More Order? Enter Y/N");

choice = in.next();

break;

case 4:

System.out.println("Welcome To St.Thomas
Mount Metro Ticket Counter ");

System.out.println("Destination
Price in Rs.");

System.out.println("1.M.G.R Central Metro


40 ");
System.out.println("2.Egmore Metro
40 ");

System.out.println("3.Nehru Park Metro


40 ");

System.out.println("4.Kilpak Metro
40 ");

System.out.println("5.Pachaiyappa's College
Metro 40 ");

System.out.println("6.Shenoy Nagar
40 ");

System.out.println("7.Anna Nagar East Metro


40 ");

System.out.println("8.Anna Nagar Tower Metro


40 ");

System.out.println("9.Thirumangalam Metro
40 ");

System.out.println("10.Koyambedu Metro
30 ");

System.out.println("11.Jayalalithaa CMBT Metro


30 ");

System.out.println("12.Arumbakkam Metro
30 ");
System.out.println("13.Vadapalani Metro
30 ");

System.out.println("14.Ashok Nagar Metro


20 ");

System.out.println("15.Ekkattuthangal Metro
20 ");

System.out.println("16.Aringar Anna Alandur


Metro 10 ");

System.out.println("");

choice = "Y";

while (choice.equalsIgnoreCase("Y"))

System.out.println("Choose the Destination by


entering Number:");

sttocen = in.nextInt();

System.out.println("Enter the Quantity");

tsttocen = in.nextInt();

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;

System.out.println("Do You Want To Place


More Order? Enter Y/N");

choice = in.next();

break;

default:

System.out.println("Choice is Wrong");

break;

System.out.println("Enter Y to go to Main Menu and N


to Print the Bill:");

choice1 = in.next();

System.out.println("Metro Ticket Booking");


System.out.println("Central To Wimco Nagar");

System.out.println("Cost for Central To Wimco Nagar=


Rs." + tamt);

System.out.println("Wimco Nagar To Central");

System.out.println("Cost From Wimco Nagar To


Central= Rs." + tamt1);

System.out.println("Central To St.Thomas");

System.out.println("Cost From Central To St.Thomas=


Rs." + tamt2);

System.out.println("St.Thomas To Central");

System.out.println("Coast From St.Thomas To Central=


Rs." + tamt3);

total = tamt + tamt1 + tamt2 + tamt3;

System.out.println("Total Amount To Be Paid = Rs." +


total);

Output:

You might also like