Railway Reservation System



Algorithm

1]Start.
2]import java.util , java.io packages.
3]Declare class rail.
4]Declare variables choice2,choice3,price,No ,checkname2,Dest,Tprice,checkage1 of Integer data type.
5] Declare variables checkname of Boolean datatype.
6] Declare array Name,classes,Subclasses,Destination of String datatype.
7] Declare choice1 variable of integer datatype
8] Create object of rail class
9] Do loop
10] try loop
11]Accept input from user and store in choice1 variable using BuffererdReader
12]switch(choice1)
case 1:obj.book()
case 2:obj.display(obj.No)
case 3:obj.cancel(obj.No)
default:Print"Invalid choice"
13]catch(NumberFormatException e)
B]Accept input from user and store in again variable using BuffererdReader
C]Invalid choice
14]if(again.equals("Y"))
call main()
else if(again.equals("y"))
call main()
else
System.exit(0);
15]End while
16]End main
17]End class



                                                            Flowchart


Source code: View on Github


Source Code: View on Github


Output:

******** RailWay Reservation System ********

1.Booking 

2.Stats 

3.Cancel

Enter your choice:1


Select your class

 1. AC 

 2. Reservation 

 3. Generalized 

 4. Back

enter your class:1


Select the sub class of ticket

 1. AC First Class 

 2. AC 2-Tier class

 3. AC 3-Tier class 

 4. First class 

 5. Exit

enter your sub-class:1

This is Ac first class


enter number of tickets:2


Enter the name of 1 passenger:Abhishek

Enter your age:17

Select your destination

1.Igatpuri 

2.Kalyan 

3.Thane 

4.Mumbai

enter your choice:1

Igatpuri


Enter the name of 2 passenger:Aniket

Enter your age:17

Select your destination

1.Igatpuri 

2.Kalyan 

3.Thane 

4.Mumbai

enter your choice:2

Kalyan

Confirm your Ticket:Y/N:Y

Ticket Confirmed

Passenger id:1

Passenger id:2

Total cost:6400


******** RailWay Reservation System ********

1.Booking 

2.Stats 

3.Cancel

Enter your choice:2


********Information of all passangers********


********1********

Name:Abhishek

Age:17

Destination:Igatpuri

OPrice:3100

Class:AC

subclass:Ac first class

PassengerId:1


********2********

Name:Aniket

Age:17

Destination:Kalyan

OPrice:3300

Class:AC

subclass:Ac first class

PassengerId:2


******** RailWay Reservation System ********

1.Booking 

2.Stats 

3.Cancel

Enter your choice:3

enter your passenger Id:2

Are you sure Y/N:y

Ticket Canceled


Comments