-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaneTicketPrices.java
44 lines (39 loc) · 1.21 KB
/
planeTicketPrices.java
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
package com.company.javapractices;
import java.util.Scanner;
public class planeTicketPrices {
public static void main(String[] args) {
int age, km, type;
double price = 0.0;
Scanner input = new Scanner(System.in);
System.out.println("type of the flight if one way press 1 if turn-return press 2");
type = input.nextInt();
System.out.println("km of flight");
km = input.nextInt();
if(km<0)
System.out.println("HATALI VERI GIRDINIZ");
System.out.println("what is your age");
age = input.nextInt();
price = km * 0.10;
if (age < 12) {
price = 0.5 * price;
if (type == 2) {
price = 0.8 * price;
}
} else if (age >= 12 && age < 24) {
price = 0.9 * price;
if (type == 2) {
price = 0.8 * price;
}
} else if (age > 65) {
price = 0.7 * price;
if (type == 2) {
price = 0.8 * price;
}
} else {
if (type == 2) {
price = 0.8 * price;
}
}
System.out.println("final price is " + price);
}
}