Program Struk Pembayaran - JAVA

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Struk_Pembayaran
{
      public static void main(String[] args)
      {
        String kode="";
        int jumlah=0;
        String cara="";
        String nama="";
        double harga=0;
        float diskon;
        int total;
        System.out.println("===================");
        System.out.println("Program Penjualan");
        System.out.println("===================");
     
        BufferedReader baca=new BufferedReader(new InputStreamReader(System.in));
        try
        {
       System.out.println("Masukan Kode Barang   :");
            kode=baca.readLine();
       System.out.println("Masukan Jumlah Barang :");
            jumlah=Integer.valueOf(baca.readLine());
       System.out.println("Masukan Cara Beli     :");
            cara=baca.readLine();
        }
        catch (IOException ex)
        {
            Logger.getLogger(Kasir_OnlineShop.class.getName()).log(Level.SEVERE, null, ex);
        }
      
        if (kode.equalsIgnoreCase("A"))
        {
            nama="Sepatu";
            harga=200000;
          
        }
        else if (kode.equalsIgnoreCase("B"))
        {
            nama="Sandal";
            harga=100000;
          
        }else if (kode.equalsIgnoreCase("C")){
            nama="T-Shirt";
            harga=250000;
        }
        else
        {
            nama="Topi";
            harga=50000;
        }
               if (cara.equalsIgnoreCase("tunai"))
               {
                    diskon=(float) (harga*0.10);
               }
               else
               {
                    diskon=0;
               }   
        harga=jumlah*harga;
        total=(int) (harga-diskon);
        System.out.println("====================");
        System.out.println("Struk Pembayaran");
        System.out.println("====================");
        System.out.println("Kode Barang    : "+kode);
        System.out.println("Nama Barang    : "+nama);
        System.out.println("Jumlah Barang  : "+jumlah);
        System.out.println("Total Harga    : "+harga);
        System.out.println("Cara Beli      : "+cara);
        System.out.println("Potongan Harga : "+diskon);
        System.out.println("Total Bayar    : "+total);     
    }
}

NEXT

No comments:

Post a Comment