Kamis, 24 Januari 2013

Buat Menu Pada Perulangan Java

Buat Menu PadaPerulangan Java 1.Masukkan list pada program sbb : importjava.util.*; public class latihan1 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int back = 1; while(back == 1) { System.out.println("MENU SEDERHANA"); System.out.println("1. BiodataMahasiswa"); System.out.println("2. Perulangan"); System.out.println("3. Keluar Program"); System.out.println(); System.out.print("MasukkanPilihan : "); intpilihan = scan.nextInt(); System.out.println(); switch(pilihan) { case 1: System.out.println("NamaMahasiswa : "); String nama = scan.next(); System.out.println("KelasMahasiswa : "); String kelas = scan.next(); System.out.println("NPM Mahasiswa : "); String npm = scan.next(); System.out.println(); System.out.println("NamaMahasiswa : " + nama); System.out.println("KelasMahasiswa : " + kelas); System.out.println("NPM Mahasiswa : " + npm); break; case 2: System.out.print("Masukkan Batas Perulangan : "); int loop = scan.nextInt(); System.out.println(); for(int i = 1; i <= loop; i++) { for(int j = 1; j <= i; j++) { System.out.print("*"); } System.out.println(); } break; case 3: System.out.println("Terimakasih"); break; } System.out.println(); System.out.print("Apakahandainginmengulang program [1/0] ? "); back = scan.nextInt(); if(back == 0) { break; } } } }

Tidak ada komentar:

Posting Komentar