import java.util.Scanner;
public class latihan {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int i;
int[] data=new int[5];
int jum=0;int rata;
garis();
System.out.println("1. MENU PILIHAN UTAMA");
garis();
System.out.println("2. MASUKAN NILAI RATA - RATA");
System.out.println("");
System.out.println("3. MASUKAN BILANGAN KELIPATAN 4");
System.out.println("");
garis();
System.out.println("Anda pilih nomor =");int pil=input.nextInt();
switch(pil){
case 1 :{
System.out.println("MASUKAN NILAI RATA - RATA");
for (i=0;i<2;i++)
{
System.out.println("data ke"+i+"=");
data[i]=input.nextInt();
jum=jum+data[i];
}
System.out.println("jumlah="+jum);
//rata=jum/i;
System.out.println("Rata-rata"+(jum/i));
break;
}
case 2 :{
System.out.println("MENGHITUNG BILANGAN KELIPATAN 4");
System.out.println("Nilai awal=");int awal=input.nextInt();
System.out.println("Nilai akhir=");int akhir=input.nextInt();
for (int s=awal;s<=akhir;s++){
if (s%4==0){
System.out.println(s);
}
}
break;
}
default :System.exit(0);
}
}
static void garis(){
System.out.println("-------------------------------------------");
}
}
0 komentar:
Posting Komentar