PROGAM KASIR PERULANGAN BERSARANG

Saya akan membagikan source code untuk progam kasir yang memiliki fitur yaitu kasir, admin, owner. menggunakan aplikasi NetBeans berikut source code progamnya :



package perulangan;

import java.util.Scanner;

import java.text.NumberFormat;

import java.util.Locale;

public class PerulanganBersarang {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance(new Locale("id", "ID"));


        double hargaVario125 = 25000000, hargaVario150 = 30000000, hargaVario160 = 35000000;

        double hargaSupraX = 15000000, hargaRevo110 = 18000000, hargaAstreaLegenda = 10000000;

        double grandTotal = 0, total = 0, bayar, kembalian;

        double totalPemasukan = 0;

        int pilih1, pilih2, pilih3 = 0, jumlah;


        do {

            System.out.print("\n================================");

            System.out.println("\nProgram Kasir");

            System.out.println("1. Aplikasi Kasir \n2. Aplikasi Admin \n3. Aplikasi Owner \n4. Exit");

            System.out.print("Pilih = ");

            pilih1 = sc.nextInt();


            switch (pilih1) {

                case 1: // Aplikasi Kasir

                    grandTotal = 0; 

                    do {

                        System.out.print("\n================================");

                        System.out.println("\nAplikasi Kasir");

                        System.out.println("1. Motor Matic \n2. Motor Bebek \n3. Selesai");

                        System.out.print("Pilih = ");

                        pilih2 = sc.nextInt();


                        switch (pilih2) {

                            case 1:

                                do {

                                    System.out.print("\n================================");

                                    System.out.println("\nMotor Matic");

                                    System.out.println("1. Vario 125   [ " + currencyFormatter.format(hargaVario125) + " ]");

                                    System.out.println("2. Vario 150   [ " + currencyFormatter.format(hargaVario150) + " ]");

                                    System.out.println("3. Vario 160   [ " + currencyFormatter.format(hargaVario160) + " ]");

                                    System.out.println("4. Back");

                                    System.out.print("Pilih = ");

                                    pilih3 = sc.nextInt();


                                    switch (pilih3) {

                                        case 1:

                                            System.out.println("\nVario 125 [ " + currencyFormatter.format(hargaVario125) + " ]");

                                            System.out.print("Jumlah beli = ");

                                            jumlah = sc.nextInt();

                                            total = jumlah * hargaVario125;

                                            grandTotal += total;

                                            break;


                                        case 2:

                                            System.out.println("\nVario 150 [ " + currencyFormatter.format(hargaVario150) + " ]");

                                            System.out.print("Jumlah beli = ");

                                            jumlah = sc.nextInt();

                                            total = jumlah * hargaVario150;

                                            grandTotal += total;

                                            break;


                                        case 3:

                                            System.out.println("\nVario 160 [ " + currencyFormatter.format(hargaVario160) + " ]");

                                            System.out.print("Jumlah beli = ");

                                            jumlah = sc.nextInt();

                                            total = jumlah * hargaVario160;

                                            grandTotal += total;

                                            break;


                                        case 4:

                                            break;


                                        default:

                                            System.out.println("Pilihan tidak ditemukan");

                                            break;

                                    }

                                } while (pilih3 != 4);

                                break;


                            case 2:

                                do {

                                    System.out.print("\n================================");

                                    System.out.println("\nMotor Bebek");

                                    System.out.println("1. Supra X [ " + currencyFormatter.format(hargaSupraX) + " ]");

                                    System.out.println("2. Revo 110 [ " + currencyFormatter.format(hargaRevo110) + " ]");

                                    System.out.println("3. Astrea Legenda [ " + currencyFormatter.format(hargaAstreaLegenda) + " ]");

                                    System.out.println("4. Back");

                                    System.out.print("Pilih = ");

                                    pilih3 = sc.nextInt();


                                    switch (pilih3) {

                                        case 1:

                                            System.out.println("\nSupra X [ " + currencyFormatter.format(hargaSupraX) + " ]");

                                            System.out.print("Jumlah beli = ");

                                            jumlah = sc.nextInt();

                                            total = jumlah * hargaSupraX;

                                            grandTotal += total;

                                            break;


                                        case 2:

                                            System.out.println("\nRevo 110 [ " + currencyFormatter.format(hargaRevo110) + " ]");

                                            System.out.print("Jumlah beli = ");

                                            jumlah = sc.nextInt();

                                            total = jumlah * hargaRevo110;

                                            grandTotal += total;

                                            break;


                                        case 3:

                                            System.out.println("\nAstrea Legenda [ " + currencyFormatter.format(hargaAstreaLegenda) + " ]");

                                            System.out.print("Jumlah beli = ");

                                            jumlah = sc.nextInt();

                                            total = jumlah * hargaAstreaLegenda;

                                            grandTotal += total;

                                            break;


                                        case 4:

                                            break;


                                        default:

                                            System.out.println("Pilihan tidak ditemukan");

                                            break;

                                    }

                                } while (pilih3 != 4);

                                break;


                            case 3:

                                System.out.println("\n================================");

                                System.out.println("Total Pembelian: " + currencyFormatter.format(grandTotal));

                                System.out.print("Masukkan uang bayar: Rp ");

                                bayar = sc.nextDouble();


                                if (bayar >= grandTotal) {

                                    kembalian = bayar - grandTotal;

                                    System.out.println("Kembalian: " + currencyFormatter.format(kembalian));

                                    totalPemasukan += grandTotal; 

                                } else {

                                    System.out.println("Uang tidak cukup. Transaksi dibatalkan.");

                                }

                                break;


                            default:

                                System.out.println("Pilihan tidak ditemukan");

                                break;

                        }

                    } while (pilih2 != 3);

                    break;


                

                    case 2: // Aplikasi Admin

    do {

        System.out.print("\n================================");

        System.out.println("\nAplikasi Admin");

        System.out.println("1. Motor Matic \n2. Motor Bebek \n3. Selesai");

        System.out.print("Pilih = ");

        pilih2 = sc.nextInt();


        switch (pilih2) {

            case 1:

                do {

                    System.out.print("\n================================");

                    System.out.println("\nUbah Harga Motor Matic");

                    System.out.println("1. Vario 125  [ " + currencyFormatter.format(hargaVario125) + " ]");

                    System.out.println("2. Vario 150  [ " + currencyFormatter.format(hargaVario150) + " ]");

                    System.out.println("3. Vario 160  [ " + currencyFormatter.format(hargaVario160) + " ]");

                    System.out.println("4. Back");

                    System.out.print("Pilih = ");

                    pilih3 = sc.nextInt();


                    switch (pilih3) {

                        case 1:

                            System.out.print("Masukkan harga baru untuk Vario 125: Rp ");

                            hargaVario125 = sc.nextDouble();

                            System.out.println("Harga baru Vario 125 berhasil diubah menjadi: " + currencyFormatter.format(hargaVario125));

                            break;


                        case 2:

                            System.out.print("Masukkan harga baru untuk Vario 150: Rp ");

                            hargaVario150 = sc.nextDouble();

                            System.out.println("Harga baru Vario 150 berhasil diubah menjadi: " + currencyFormatter.format(hargaVario150));

                            break;


                        case 3:

                            System.out.print("Masukkan harga baru untuk Vario 160: Rp ");

                            hargaVario160 = sc.nextDouble();

                            System.out.println("Harga baru Vario 160 berhasil diubah menjadi: " + currencyFormatter.format(hargaVario160));

                            break;


                        case 4:

                            break;


                        default:

                            System.out.println("Pilihan tidak ditemukan");

                            break;

                    }

                } while (pilih3 != 4);

                break;


            case 2:

                do {

                    System.out.print("\n================================");

                    System.out.println("\nUbah Harga Motor Bebek");

                    System.out.println("1. Supra X  [ " + currencyFormatter.format(hargaSupraX) + " ]");

                    System.out.println("2. Revo 110 [ " + currencyFormatter.format(hargaRevo110) + " ]");

                    System.out.println("3. Astrea Legenda [ " + currencyFormatter.format(hargaAstreaLegenda) + " ]");

                    System.out.println("4. Back");

                    System.out.print("Pilih = ");

                    pilih3 = sc.nextInt();


                    switch (pilih3) {

                        case 1:

                            System.out.print("Masukkan harga baru untuk Supra X: Rp ");

                            hargaSupraX = sc.nextDouble();

                            System.out.println("Harga baru Supra X berhasil diubah menjadi: " + currencyFormatter.format(hargaSupraX));

                            break;


                        case 2:

                            System.out.print("Masukkan harga baru untuk Revo 110: Rp ");

                            hargaRevo110 = sc.nextDouble();

                            System.out.println("Harga baru Revo 110 berhasil diubah menjadi: " + currencyFormatter.format(hargaRevo110));

                            break;


                        case 3:

                            System.out.print("Masukkan harga baru untuk Astrea Legenda: Rp ");

                            hargaAstreaLegenda = sc.nextDouble();

                            System.out.println("Harga baru Astrea Legenda berhasil diubah menjadi: " + currencyFormatter.format(hargaAstreaLegenda));

                            break;


                        case 4:

                            break;


                        default:

                            System.out.println("Pilihan tidak ditemukan");

                            break;

                    }

                } while (pilih3 != 4);

                break;


            case 3:

                break;


            default:

                System.out.println("Pilihan tidak ditemukan");

                break;

        }

    } while (pilih2 != 3);

    break;


                case 3: // Aplikasi Owner

                    System.out.print("\n================================");

                    System.out.println("\nAplikasi Owner");

                    System.out.println("Total Semua Pemasukan: " + currencyFormatter.format(totalPemasukan));

                    break;


                case 4:

                    System.out.println("Keluar dari program. Terima kasih!");

                    break;


                default:

                    System.out.println("Pilihan tidak ditemukan");

                    break;

            }

        } while (pilih1 != 4);

    }

}



INILAH HASIL OUTPUTNYA JIKA INGIN LEBIH JELAS SILAHKAN MENCOBA SENDIRI








Komentar

Postingan Populer