Untitled

Run Settings
LanguageJava
Language Version
Run Command
import java.util.Scanner; public class KonversiSuhu { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Pilih konversi suhu:"); System.out.println("1. Celcius ke Fahrenheit"); System.out.println("2. Celcius ke Kelvin"); System.out.println("3. Fahrenheit ke Celcius"); System.out.println("4. Fahrenheit ke Kelvin"); System.out.println("5. Kelvin ke Celcius"); System.out.println("6. Kelvin ke Fahrenheit"); System.out.print("Masukkan pilihan: "); int pilihan = scanner.nextInt(); double suhu, suhuHasil; if (pilihan == 1) { System.out.print("Masukkan suhu Celcius: "); suhu = scanner.nextDouble(); suhuHasil = (suhu * 9/5) + 32; System.out.println("Suhu Fahrenheit: " + suhuHasil); } else if (pilihan == 2) { System.out.print("Masukkan suhu Celcius: "); suhu = scanner.nextDouble(); suhuHasil = suhu + 273.15; System.out.println("Suhu Kelvin: " + suhuHasil); } else if (pilihan == 3) { System.out.print("Masukkan suhu Fahrenheit: "); suhu = scanner.nextDouble(); suhuHasil = (suhu - 32) * 5/9; System.out.println("Suhu Celcius: " + suhuHasil); } else if (pilihan == 4) { System.out.print("Masukkan suhu Fahrenheit: "); suhu = scanner.nextDouble(); suhuHasil = (suhu - 32) * 5/9 + 273.15; System.out.println("Suhu Kelvin: " + suhuHasil); } else if (pilihan == 5) { System.out.print("Masukkan suhu Kelvin: "); suhu = scanner.nextDouble(); suhuHasil = suhu - 273.15; System.out.println("Suhu Celcius: " + suhuHasil); } else if (pilihan == 6) { System.out.print("Masukkan suhu Kelvin: "); suhu = scanner.nextDouble(); suhuHasil = (suhu - 273.15) * 9/5 + 32; System.out.println("Suhu Fahrenheit: " + suhuHasil); } else { System.out.println("Pilihan tidak valid"); } } }
Editor Settings
Theme
Key bindings
Full width
Lines