Contoh Program Array Java
import java.io.*;
public class latihcase
{
public static void main
(String[]args)throws IOException
{
int kode;
double total;dropdown
double harga;
double jumlah;
double diskon;
double bayar;
int i;
int angka[]=new int [4];
BufferedReader br;
br=new BufferedReader(new
InputStreamReader(System.in));
for(i=1; i<angka.length;i++)
{
angka[i]=i;
System.out.println("Data Ke
"+angka[i]);
System.out.print("Masukan
kode=");
kode=Integer.parseInt(br.readLine());
System.out.print("Masukan
jumlah=");
jumlah=Integer.parseInt(br.readLine());
System.out.print("Masukan
Diskon (%)=");
diskon=Integer.parseInt(br.readLine());
switch (kode)
{
case 1:
System.out.println("Buku");
harga=2000;
System.out.println("harga="+harga);
total=jumlah*harga;
System.out.println("total="+total);
bayar=(100-diskon)/100*total;
System.out.println("bayar="+bayar);
break;
case 2:
System.out.println("Pensil");
harga=3000;
System.out.println("harga="+harga);
total=jumlah*harga;
System.out.println("total="+total);
bayar=(100-diskon)/100*total;
System.out.println("bayar="+bayar);
break;
case 3:
System.out.println("Bolpoint");
harga=4000;
System.out.println("harga="+harga);
total=jumlah*harga;
System.out.println("total="+total);
bayar=(100-diskon)/100*total;
System.out.println("bayar="+bayar);
break;
default:
}
}
}
}
nice share gan, untuk program pencarian nilai Array bisa kunjungi di :
ReplyDeletehttp://top-ilmu.blogspot.com/2012/10/contoh-program-java-pencarian-searching.html
Mksih gan. :)
ok sama2, kunjungan balik
ReplyDelete