import java.util.Scanner;
class java {
Scanner input = new Scanner(System.in);
public void dowhile(){
int i;
i=18;
System.out.println("Looping dengan do-while");
do{
System.out.println("Hello kelas 1IA"+i);
i++;
}
while (i<=25);
}
public void kondisi() {
int a;
a =2;
System.out.println("7 Keajaiban Dunia");
System.out.println("1.Pyramida");
System.out.println("2.Tembok cina");
System.out.println("3.Menara miring");
System.out.println("4.Candi borobudur");
System.out.println("5.Taj mahal");
System.out.println("6.Coloseum");
System.out.println("7.taman gantung babilonia");
System.out.println("Pilihan anda adalah = "+a);
switch (a) {
case 1:
System.out.println("1.Pyramida");
break;
case 2:
System.out.println("2.Tembok cina");
break;
case 3:
System.out.println("3.Menara miring");
break;
case 4:
System.out.println("4.Candi borobudur");
break;
case 5:
System.out.println("5.Taj mahal");
break;
case 6:
System.out.println("6.Coloseum");
break;
case 7:
System.out.println("7.taman gantung babilonia");
break;
default:
System.out.println("Pilihan anda adalah");
}
}
public void menu(){
System.out.println("Menu Program Hitung Volume Benda");
System.out.println("1. Do while");
System.out.println("2. IF kondisi");
System.out.println("0. Exit");
System.out.print("Masukkan Pilihan Anda : ");
int choice = input.nextInt();
switch(choice){
case 1: dowhile();
cekdata();
break;
case 2: kondisi();
cekdata();
break;
case 0: System.exit(0);
default:
System.out.println("Pilihan Tidak Ada, Silahkan Kembali Memilih");
System.out.println("");
menu();
}
}
public void cekdata(){
System.out.print("Kembali ke Menu? (Y/T) : ");
String cek = input.next();
if(cek.equals("Y")|cek.equals("y")|cek.equals("YA")|cek.equals("ya")|cek.equals("Ya")){
menu();
}
else{
System.exit(0);
}
}
public static void main (String[]args){
java objek = new java();
objek.menu();
}
}
Wednesday, November 27, 2013
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment