Source Code :
import java.io.InputStreamReader;
import java.io.IOException;
import javax.swing.WindowConstants;
public class XariRoti
{
public static void main (String [] str)
{
InputStreamReader stream = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(stream);
int harga = 0;
int jml = 0, pilihan = 0, bayar;
String input;
System.out.println("\n\n\n| ====================================================== |");
System.out.println("| |");
System.out.println("| PROGRAM KASIR SEDERHANA - XARI ROTI |");
System.out.println("| |");
System.out.println("| ============================================================ |");
System.out.println("| Menu: |");
System.out.println("| 1. Roti Coklat : Rp. 5.000 |");
System.out.println("| 2. Roti Pisang : Rp. 4.000 |");
System.out.println("| |");
System.out.print("| Pilih : |");
for(int i = 0; i < 48; i++)
System.out.printf("\b");
try
{
input = in.readLine();
pilihan = Integer.parseInt(input);
System.out.println("| |");
System.out.print("| Jumlah: |");
for(int i = 0; i < 48; i++)
System.out.printf("\b");
input = in.readLine();
jml = Integer.parseInt(input);
}
catch (IOException e)
{
System.out.println("| IO Error |");
System.out.println("| ====================================================== |");
System.out.println("\n\n\n" + e + "\n\n\n");
System.exit(WindowConstants.DISPOSE_ON_CLOSE);
}
catch (Exception e)
{
System.out.println("| General Error |");
System.out.println("| ====================================================== |");
System.out.println("\n\n\n" + e + "\n\n\n");
System.exit(WindowConstants.DISPOSE_ON_CLOSE);
}
switch(pilihan)
{
case 1: harga = 5000;
break;
case 2: harga = 4000;
break;
default : System.out.println("| Pilihan Tidak Tersedia |");
System.out.println("| ====================================================== |");
System.exit(WindowConstants.DISPOSE_ON_CLOSE);
}
if(jml >= 6)
bayar = (harga * (jml - 2));
else if(jml >= 3)
bayar = (harga * (jml - 1));
else
bayar = harga * jml;
System.out.println("| ====================================================== |");
System.out.print("| Total Bayar : Rp. |");
for(int i = 0; i < 39; i++)
System.out.printf("\b");
System.out.println(Integer.toString(bayar));
System.out.println("| ====================================================== |\n\n\n");
}
}
Outputnya :
0 comments:
:)) :)] ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} ~x( :-t b-( :-L x( =))
Post a Comment