forked from dicodingacademy/BelajarJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuhuAir.java
More file actions
29 lines (23 loc) · 878 Bytes
/
SuhuAir.java
File metadata and controls
29 lines (23 loc) · 878 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
package com.dicoding.javafundamental.suhuair;
import java.util.Scanner;
public class SuhuAir {
public static void main(String[] args) {
/* contoh pemakaian IF tiga kasus : wujud air */
/*Kamus*/
int T;
/*Program*/
System.out.println("Contoh IF tiga kasus");
System.out.print("Temperatur (der. C) = ");
//scanner untuk masukan temperatur air
Scanner scanner = new Scanner(System.in);
T = scanner.nextInt(); //masukan temperatur air dengan tipe int
//proses pengecekan dengan if
if (T < 0) {
System.out.println("Wujud air beku " + T);
} else if ((0 <= T) && (T <= 100)) {
System.out.println("Wujud air cair " + T);
} else if (T > 100) {
System.out.println("Wujud air uap/gas " + T);
}
}
}