Belajar Switch

Run Settings
LanguageJava
Language Version
Run Command
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); String inisial, hasil; System.out.print("Masukkan inisial [A...D]: "); inisial = input.nextLine(); switch (inisial) { case "A": hasil = "Apple"; break; case "B": hasil = "Banana"; break; case "C": hasil = "Cherry"; break; case "D": hasil = "Durian"; break; default: hasil = "Salah"; } System.out.printf("Anda memasukkan %s, hasilnya %s", inisial, hasil); } }
Editor Settings
Theme
Key bindings
Full width
Lines