Contoh Program Kasir Sederhana Dengan Java
import java.io.*;
public class tgs2
{
public static void main
(String[]args)throws IOException
{
int kode;
double total;
double harga;
double jumlah;
double diskon;
double banyak;
double bayar;
double kembali;
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("banyaknya=");
banyak=Integer.parseInt(br.readLine());
System.out.print("Masukan
Diskon (%)=");
diskon=Integer.parseInt(br.readLine());
System.out.print("bayar=");
bayar=Integer.parseInt(br.readLine());
switch (kode)
{
case 1:
System.out.println("Buku");
harga=2000;
System.out.println("harga="+harga);
jumlah=banyak*harga;
System.out.println("total="+banyak);
total=(100-diskon)/100*jumlah;
System.out.println("total="+total);
kembali=bayar-total;
System.out.println("kembali="+kembali);
break;
case 2:
System.out.println("Pensil");
harga=3000;
System.out.println("harga="+harga);
jumlah=banyak*harga;
System.out.println("total="+banyak);
total=(100-diskon)/100*jumlah;
System.out.println("total="+total);
kembali=bayar-total;
System.out.println("kembali="+kembali);
break;
case 3:
System.out.println("Bolpoint");
harga=4000;
System.out.println("harga="+harga);
jumlah=banyak*harga;
System.out.println("total="+banyak);
total=(100-diskon)/100*jumlah;
System.out.println("total="+total);
kembali=bayar-total;
System.out.println("kembali="+kembali);
break;
default:
}
}
}
}
kalo yang pake perkodisian bgmana bro ?
ReplyDelete