-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlightTicket.java
More file actions
30 lines (29 loc) · 895 Bytes
/
FlightTicket.java
File metadata and controls
30 lines (29 loc) · 895 Bytes
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
package Cases;
public class FlightTicket {
public static void main(String[] args) {
double price = calculate(1000, 8, "economy class");
System.out.println("Discounted price is: " + price);
}
public static double calculate(double price, int month, String type){
if(month >= 5 && month <= 10){
switch (type){
case "first class":
price = price * 9;
break;
case "economy class":
price *= 0.85;
break;
}
}else{
switch (type){
case "first class":
price *= 0.7;
break;
case "economy class":
price *= 0.65;
break;
}
}
return price;
}
}