-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathucakbileti.java
More file actions
56 lines (46 loc) · 1.49 KB
/
ucakbileti.java
File metadata and controls
56 lines (46 loc) · 1.49 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
import java.util.Scanner;
public class ucakbileti {
public static void main(String[] args) {
int distance,age,ticketType;
Scanner inp = new Scanner(System.in);
System.out.println("enter informations...");
System.out.println("distance:");
distance = inp.nextInt();
System.out.println("age:");
age = inp.nextInt();
System.out.println("ticket type (one way = 1 round-trip = 2):");
ticketType = inp.nextInt();
double total=0;
if( distance>0 && age > 0 && (ticketType == 1 || ticketType == 2)){
total = distance*0.10;
if(age<12){
total *= 0.5;
if(ticketType == 2){
total -= total*0.2;
total *=2;
}
}else if(age<24){
total -= total*0.10;
if(ticketType == 2){
total -= total*0.2;
total *=2;
}
}else if(age< 65){
if(ticketType == 2){
total -= total*0.2;
total *=2;
}
}else{
total -= total*0.3;
if(ticketType == 2){
total -= total*0.2;
total *=2;
}
}
System.out.println("total ="+ total);
}else{
System.out.println("you entered wrong information!");
}
inp.close();
}
}