-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrainSeatReservation.java
More file actions
58 lines (52 loc) · 1.39 KB
/
TrainSeatReservation.java
File metadata and controls
58 lines (52 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.Scanner;
public class TrainSeatReservation
{
//instance variables
String coach;
double amt;
double cost = 0.0 ;
//default Constructor
TrainSeatReservation()
{
this.coach = " ";
this.amt = 0.0 ;
this.cost = 0.0 ;
}
//member mothods
void accept()
{
//Declaration
Scanner input = new Scanner(System.in);
InputDetails obj1 = new InputDetails();
//prompt and accept the values
System.out.println("Coach: \n(a) First_AC \n(b) Second_AC \n(c) Third_Ac \n(d) Sleeper");
this.coach = input.nextLine().trim();
System.out.println("Your coach's base amount: ");
this.amt = input.nextDouble();
}
void update()
{
if(this.coach.equalsIgnoreCase("a"))
{
this.cost = this.amt + 700;
}
else if(this.coach.equalsIgnoreCase("b"))
{
this.cost = this.amt + 500;
}
else if(this.coach.equalsIgnoreCase("c"))
{
this.cost = this.amt + 250;
}
else
{
this.cost = this.amt;
}
}
void display(InputDetails obj1)
{
System.out.println("Name: " + obj1.name);
System.out.println("Date of Travel: " + obj1.date);
System.out.println("Coarch: " + this.coach);
}
}