0% found this document useful (0 votes)
252 views

Tugas 2 Pemrograman Berbasis Desktop Habib

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
252 views

Tugas 2 Pemrograman Berbasis Desktop Habib

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

LINK VIDEO :

https://youtu.be/dVeNpyISk4k?si=p1MiZJfVz1_Yt8Ux
package com.mycompany.restaurantapp;
import java.Until.Scanner;
class MenuItam {
String nama;
double price;
String Category;
MenuItem(String nama, double price, String category) {
this.name = name;
this.price = price;
this.category = category;
}
}
public class RestaurantApp {
static Scanner scanner = new Scanner (System.in);
static MenuItem[] menu = {
new MenuItem("Nasi Goreng", price : 25000, category : "makanan"),
new MenuItem("Ayam Goreng", price : 30000, category : "makanan"),
new MenuItem("Es Teh", price : 50000, category : "minuman"),
new MenuItem("Es Jeruk", price : 70000, category : "minuman"),
};
public static void main(String[] args) {
ShowMainMenu();
}
static void showMainMenu() {
while (true) {
System.out.println("===== Restoran XYZ =====");
System.out.println("1. Pesan Makanan");
System.out.println("2. Kelola Menu Restoran");
System.out.println("3. Keluar");
System.out.println("Pilih Menu : ");
int choice = scanner.nextInt();
scanner.nextLine();
switch (choice) {
case 1:
orderFood();
break;
case 2:
ManageMenu();
break;
case 3:
System.out.println("Terimakasih telah menggunakan layanan kami");
return;
default;
System.outprintln("Pilihan tidak valid, Silahkan coba lagi");
}
}
}
static void orderFood() {
System.outprintln("===== Daftar Menu =====");
for (int i =0; i < menu.lenght; i++) {
System.outprintln((i + 1)+ ", "+ menu[i].nama + " - Rp "+ menu[i].price);
}
System.out.println("Masukkan Nnomor mwnu yang ingin dipesan atau 'selesai' untuk
selesai.");
double totalCost = 0;
while (true) {
System.out.println("Pesan : ");
String input = scanner.nextLine();
if (input.equalsIgnoreCase("Selesai")) {
break;
}
try {
int menuItemIndex = Integer.parseInt(input) - 1;
if (menuItemIndex >= 0 && menuItemIndex < menu.lenght) {
System.outprintln("Jumlah : ");
int quantity = scanner.nextInt();
scanner.nextLine();
totalCost += menu[menuItemIndex].price * quantity;
}else {
System.outprintln("Menu tidak valid. Silahkan coba lagi.");
}
} catch (NumberFormatException e) {
System.out.println("Input tidak valid. Silahkan coba lagi");
}
}
double tax = totalCost * 0.1;
double serviceCharge = 20000;
double totalBill = totalCost + tax + serviceCharge;
System.out.println("\n***** Struk Pesanan *****");
System.out.println("Total Biaya : Rp "+ totalCost);
System.out.println("Pajak (10%) : Rp "+ tax);
System.out.println("Biaya Pelayanan : Rp "+ serviceCharge);
if (totalCost > 100000) {
double discount = totalCost * 0.1;
totalBill -= discount;
System.out.println("Diskon 10% : -Rp "+ discount);
}
if (totalCost > 50000) {
System.out.println("Penawaran beli satu gratis satu -Rp "+ menu[2].price);
totalBill -= menu[2].price;
}
System.out.println("Total Tagihan: Rp "+ totalBill);
}
static void manageMenu() {
System.out.println("===== Kelola Menu =====");
while (true) {
System.out.println("1. Tambah Menu");
System.out.println("2. Ubah Harga Menu");
System.out.println("3. Hapus Menu");
System.out.println("4. Kembali");
System.out.println("Pilih Menu : ");
int choice = scanner.nextInt();
scanner.nextLine();
switch (choice) {
case 1:
addMenuItem();
break;
case 2:
aditMenuItem();
break;
case 3:
deleteMenuItem();
break;
case 4:
return;
default:
System.out.println("Pilihan menu tidak valid. Silahkan coba lagi.");
}
}
}

static void addMenuItem() {


System.out.println("Menu untuk menambahkan item menu beru belum
diimplementasikan.");
}
static void aditMenuItem() {
System.out.println("Menu untuk mengubah item menu belum diimplementasikan.");
}
static void deleteMenuItem() {
System.out.println("Menu untuk menghapus item menu belum diimplementasikan.");
}
}

You might also like