Skip to content

Commit a22dce8

Browse files
Add files via upload
0 parents  commit a22dce8

File tree

3 files changed

+455
-0
lines changed

3 files changed

+455
-0
lines changed

TASK_1.java

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import java.util.*;
2+
3+
class Authentication{
4+
static HashMap<String,String> login = new HashMap<String,String>();
5+
static Scanner in = new Scanner(System.in);
6+
List<Integer> Pnr_no = new ArrayList<Integer>();
7+
Dictionary trainList = new Hashtable();
8+
// Dictionary passgr_detail = new Hashtable();
9+
HashMap<String,String[]> passengers = new HashMap<String,String[]>();
10+
Dictionary<Integer, String> passgr_detail = new Hashtable<Integer, String>();
11+
12+
public static void Start()
13+
{}
14+
15+
16+
void Sign_up() {
17+
18+
String username,password;
19+
System.out.println("Enter Username");
20+
username=in.nextLine();
21+
System.out.println("Enter Password");
22+
password=in.nextLine();
23+
login.put(username,password);
24+
25+
}
26+
27+
void Sign_in() {
28+
String inusername,inpassword;
29+
int ch;
30+
Scanner in = new Scanner(System.in);
31+
System.out.println("Enter Username");
32+
inusername=in.nextLine();
33+
System.out.println("Enter Password");
34+
inpassword=in.nextLine();
35+
36+
37+
//Check whether entered password with username
38+
if (inpassword.equals(login.get(inusername))){
39+
options();
40+
41+
}
42+
else
43+
{
44+
System.out.println("Password invalid");
45+
}
46+
}
47+
48+
public void options() {
49+
System.out.println("1.Reservation Details");
50+
System.out.println("2.Cancellation");
51+
System.out.println("Enter Choice");
52+
int ch = in.nextInt();
53+
54+
switch (ch){
55+
56+
case 1:
57+
Reservation_sys();
58+
break;
59+
60+
case 2:
61+
cancellation();
62+
break;
63+
64+
default:
65+
System.out.println("Enter Valid Choice");
66+
67+
}
68+
69+
}
70+
71+
public void cancellation() {
72+
Integer PNR_no;
73+
System.out.println("Enter PNR Number");
74+
PNR_no = in.nextInt();
75+
76+
77+
System.out.println("Details" + passgr_detail.get(trainList));
78+
System.out.println("\n");
79+
80+
81+
82+
options();
83+
84+
}
85+
86+
public void Reservation_sys() {
87+
Scanner in =new Scanner(System.in);
88+
89+
90+
trainList.put("10022","LTT");
91+
trainList.put("10023","Pudocherry Express");
92+
trainList.put("10024","Chennai Express");
93+
String train_no;
94+
String class_type,date,from_place,to_place;
95+
96+
int n =trainList.size();
97+
for (int i = 0; i < n; i++) {
98+
99+
100+
System.out.println("Enter Train Number");
101+
System.out.println("10022\n" + "10023\n" + "10024\n");
102+
train_no = in.nextLine();
103+
passgr_detail.put(1, train_no);
104+
//passgr_detail.put((String) trainList.get(train_no));
105+
System.out.println("Train Name is :" + trainList.get(train_no));
106+
System.out.println("Enter Class type ");
107+
class_type = in.nextLine();
108+
passgr_detail.put(1,class_type);
109+
System.out.println("Enter Date of Journey");
110+
date = in.nextLine();
111+
passgr_detail.put(1, date);
112+
System.out.println("Enter From place :");
113+
from_place = in.nextLine();
114+
passgr_detail.put(1,from_place);
115+
System.out.println("Enter Destination place");
116+
to_place = in.nextLine();
117+
passgr_detail.put(1,to_place);
118+
System.out.println("Enter insert");
119+
String insert = in.nextLine();
120+
options();
121+
122+
}
123+
124+
125+
126+
127+
}
128+
}
129+
130+
public class TASK_1 {
131+
public static void main(String[] args) {
132+
Scanner in = new Scanner(System.in);
133+
Authentication obj = new Authentication();
134+
do {
135+
System.out.println("1.Sign In");
136+
System.out.println("2.Sign Up");
137+
System.out.println("Enter Choice");
138+
int ch = in.nextInt();
139+
switch (ch) {
140+
case 1 -> obj.Sign_in();
141+
case 2 -> obj.Sign_up();
142+
default -> System.out.println("Enter valid choice");
143+
}
144+
}while (true);
145+
}
146+
147+
148+
149+
}
150+

TASK_2.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import java.util.Scanner;
2+
3+
public class TASK_2 {
4+
5+
// Function that implements the
6+
// number guessing game
7+
public static void numberGuessingGame()
8+
{
9+
// Scanner Class
10+
Scanner sc = new Scanner(System.in);
11+
12+
// Generate the numbers
13+
int number = 1 + (int)(100 * Math.random());
14+
15+
// Given K trials
16+
int K = 5;
17+
18+
int i, guess;
19+
20+
System.out.println("A number is chosen between 1 to 100."
21+
+ "Guess the number within 5 trials.");
22+
23+
24+
for (i = 0; i < K; i++) {
25+
26+
System.out.println(
27+
"Guess the number:");
28+
29+
// Take input for guessing
30+
guess = sc.nextInt();
31+
32+
// If the number is guessed
33+
if (number == guess) {
34+
System.out.println(
35+
"Congratulations!"
36+
+ " You guessed the number.");
37+
break;
38+
}
39+
else if (number > guess && i != K - 1) {
40+
System.out.println("The number is greater than " + guess);
41+
}
42+
else if (number < guess && i != K - 1) {
43+
System.out.println("The number is less than " + guess);
44+
}
45+
}
46+
47+
if (i == K) {
48+
System.out.println("You have exhausted " + K +" trials.");
49+
50+
System.out.println("The number was " + number);
51+
}
52+
}
53+
54+
55+
public static void main(String arg[])
56+
{
57+
58+
59+
numberGuessingGame();
60+
}
61+
}
62+

0 commit comments

Comments
 (0)