-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathCarparkRate.java
More file actions
42 lines (40 loc) · 1.17 KB
/
Copy pathCarparkRate.java
File metadata and controls
42 lines (40 loc) · 1.17 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
package Exercise;
import java.util.Scanner;
public class CarparkRate {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int HourIn, MinIn, HourOut, MinOut,Mintt,RateH,RateM,Value;
System.out.print("Time In: ");
HourIn=input.nextInt();
MinIn=input.nextInt();
System.out.print("Time Out: ");
HourOut=input.nextInt();
MinOut=input.nextInt();
Mintt=((HourOut*60)-(HourIn*60))+(MinOut-MinIn);
if(Mintt<=15){
Value=0;
}else if(Mintt<=180){
RateH=Mintt/60;
RateM=Mintt%60;
if(RateM==0){
RateH=RateH+0;
}else{
RateH=RateH+1;
}
Value=RateH*10;
}else if(Mintt<=360){
RateH=Mintt/60;
RateM=Mintt%60;
if(RateM==0){
RateH=RateH+0;
}else{
RateH=RateH+1;
}
Value=30+(RateH-3)*20;
}else{
Value=200;
}
System.out.println("Min: "+Mintt+" mins");
System.out.println("Value: "+Value+" baht");
}
}