class ContohIfElse {
public static void main(String[] args) {
char HurufDepan = (char) -1 ;
System.out.println(“masukan huruf depan kamu!!!”);
try {
HurufDepan = (char) System.in.read();
} catch (Exception e) {
System.out.println(“error : ” + e.toString());
}
if (HurufDepan = -1) {
System.out.println(“kok g nurut sama perintah??”);
} else if (HurufDepan == ‘a’) {
System.out.println(“apa namamu adul?”);
} else if (HurufDepan == ‘b’) {
System.out.println(“apa namamu beni?”);
} else if (HurufDepan == ‘c’) {
System.out.println(“apa namamu cesa?”);
} else if (HurufDepan == ‘d’) {
System.out.println(“apa namamu deni?”);
} else if (HurufDepan == ‘i’) {
System.out.println(“apa nammu iyus?”);
} else {
System.out.println(“waduh!!!,belom bisa nebak nieh!!!”);
}
}
}
hasil outputnya