Program Arham Coffee - JAVA

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.Scanner;

public class Arham_Coffee
{
    static BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
    static Scanner inputan = new Scanner(System.in);
    static DecimalFormat titik_uang = new DecimalFormat("#,##0");
    static String menu = "";
    static String tanya = "";
    static int jumlah=0;
    static int pesan, banyak;
    static int b_kopi, kopi;
    static int b_shake, shake;
    static int b_cake, cake;
    static int j_cake = 25;
    static int uang = 0;
    static int kembalian = 0;
    static int b_semua = 0;
    static int j_semua = 0;
    static int harga1 = 5000;
    static int harga2 = 7000;
    static int harga3 = 6000;
    static int h_s_k, h_s_s, h_s_c;
    static int j_k_kopi, j_k_shake, j_k_cake;
    static int j_h_kopi, j_h_shake, j_h_cake;
    static boolean x;

    public static void main(String[] agrs) {
        do {
            System.out.println("============================");
            System.out.println("The Arham Coffee");
            System.out.println("============================");
            System.out.println("A) Pesan");
            System.out.println("B) Buat Cake");
            System.out.println("C) Laporan Penjualan");
            System.out.println("D) Rubah Harga");
            System.out.println("E) Keluar");
            System.out.print("Masukkan Pilihan : ");

            try {
                menu = dataIn.readLine();
            } catch (IOException e) {
                System.out.println("Error!");
            }
            x = true;

            if ("A".equals(menu)) {
                do {
                    System.out.println("---------------------------------------------");
                    System.out.println("Pilih Menu Makanan Atau Minuman");
                    System.out.println("---------------------------------------------");
                    System.out.println("1) Kopi");
                    System.out.println("2) Shake");
                    System.out.println("3) Cake");
                    System.out.println("4) Selesai Pilih");
                    System.out.print("Pilih Menu  : ");
                    pesan = inputan.nextInt();

                    if (pesan == 1) {
                        System.out.print("Berapa Banyak Kopi Yang Ingin Dibeli  : ");
                        b_kopi = inputan.nextInt();
                        kopi = harga1 * b_kopi;     
                        h_s_k=kopi+h_s_k;
                        j_k_kopi = b_kopi + j_k_kopi;
                        j_h_kopi = kopi + j_h_kopi;
                        x = true;
                    }
                    if (pesan == 2) {
                        System.out.print("Berapa Banyak Shake Yang Ingin Dibeli : ");
                        b_shake = inputan.nextInt();
                        shake = harga2 * b_shake;
                        h_s_s=shake+h_s_s;
                        j_k_shake = b_shake + j_k_shake;
                        j_h_shake = shake + j_h_shake;
                        x = true;
                    }
                    if (pesan == 3) {
                        System.out.print("Berapa Banyak Cake Yang Ingin Dibeli  : ");
                        b_cake = inputan.nextInt();

                        if (b_cake > j_cake) {
                            System.out.println("Maaf..Kita Kehabisan Stok Cake...Silahkan Buat Lagi");
                            main(agrs);
                        } else {
                            cake = harga3 * b_cake;
                            j_cake = j_cake - b_cake;
                            h_s_c=cake+h_s_c;
                            j_k_cake = b_cake + j_k_cake;
                            j_h_cake = cake + j_h_cake;
                            x = true;
                        }
                    }

                    if (pesan == 4) {
                        jumlah = h_s_k + h_s_s + h_s_c;
                  
                        System.out.println("Total Biaya Adalah  Rp. " + titik_uang.format(jumlah) + ",-");

                        System.out.print("Masukkan Jumlah Uang Pelanggan Rp. ");
                        uang = inputan.nextInt();

                        kembalian = uang - jumlah;
                        System.out.println("Kembalian Pelanggan Rp. " + titik_uang.format(kembalian) + ",-");
                        h_s_k=0; h_s_s=0; h_s_c=0;  //Untuk mereset jumlah harga sementara
                        x = false;
                    }
                } while (x);
                x = true;
            }

            if ("B".equals(menu)) {
                j_cake = j_cake + 25;
                System.out.println("25 Cake Telah Ditambahkan, Total Cake " + j_cake);
                x = true;
            }

            if ("C".equals(menu)) {
                System.out.println("---------------------------------------------");
                System.out.println(">> Cake Yang Belum Terjual      = " + j_cake);
                System.out.println("---------------------------------------------");
                System.out.println("Total Penjualan...");
                System.out.println("---------------------------------------------");
                System.out.println("Kopi    = " + j_k_kopi + "   Rp." + titik_uang.format(j_h_kopi));
                System.out.println("Shake   = " + j_k_shake + "   Rp." + titik_uang.format(j_h_shake));
                System.out.println("Cake    = " + j_k_cake + "   Rp." + titik_uang.format(j_h_cake));
                System.out.println("---------------------------------------------");
                j_semua = j_h_shake + j_h_kopi + j_h_cake;
                System.out.println("Jumlah  =      Rp." + titik_uang.format(j_semua));
                System.out.println("Apakah Anda Ingin Mereset Laporan?");
                System.out.println("Jika Iya Tekan 'Y' Jika Tidak Tekan 'N'");
                System.out.print("Masukkan Jawaban Anda : ");
                try {
                    tanya = dataIn.readLine();
                } catch (IOException e) {
                    System.out.println("Error!");
                }
                if ("y".equals(tanya) || "Y".equals(tanya)) {
                    b_semua = 0;j_k_shake = 0;j_k_kopi = 0;j_k_cake = 0;
                    j_semua = 0;j_h_shake = 0;j_h_kopi = 0;j_h_cake = 0;
                    x=true;
                }

                if ("n".equals(tanya) || "N".equals(tanya)) {
                    x = true;
                }
            }

            if ("D".equals(menu)) {
                System.out.println("---------------------------------------------");
                System.out.println("Rubah Harga Produk-produk Di Cafe");
                System.out.println("---------------------------------------------");
                System.out.print("1. Kopi   = Rp. ");
                harga1 = inputan.nextInt();
                System.out.print("2. Shake  = Rp. ");
                harga2 = inputan.nextInt();
                System.out.print("3. Cake   = Rp. ");
                harga3 = inputan.nextInt();
                System.out.println("---------------------------------------------");
                x = true;
            }

            if ("E".equals(menu)) {
                System.out.println("Good Bye, See u");
                x = false;
            }
        } while (x);
    }
}

NEXT

No comments:

Post a Comment