0% found this document useful (0 votes)
60 views4 pages

Untitled

This document contains the code for a Java program that simulates ordering from a restaurant. It includes functions for logging in, ordering food items, calculating discounts, and delivering or picking up orders. The program prompts the user to enter login credentials, selects a food item and quantity, then calculates the total price with any applicable discounts based on the order amount. It also allows the user to choose delivery or pickup and calculates additional fees based on delivery distance. The summary function at the end prints out the transaction details.

Uploaded by

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

Untitled

This document contains the code for a Java program that simulates ordering from a restaurant. It includes functions for logging in, ordering food items, calculating discounts, and delivering or picking up orders. The program prompts the user to enter login credentials, selects a food item and quantity, then calculates the total price with any applicable discounts based on the order amount. It also allows the user to choose delivery or pickup and calculates additional fees based on delivery distance. The summary function at the end prints out the transaction details.

Uploaded by

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

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package PROLOGEXAM;

import java.util.Scanner;

public class RESTAURANT {

static double O,DP,P,DF,tP,DA,t;


static String u,p,BQ,GH,IS,DG,item,DL,PU,DM,M;
static int i,D;
static Scanner input= new Scanner(System.in);
public static void main(String[]args){
login();
order();
summary();
}
static void login(){
System.out.println("Username?");
u = input.next();
System.out.println("Password?");
p = input.next();
for(i=1;i<=3;i++){
if(u.equals("waymond") && p.equals("0609")){
break;
}
if(i==3){
System.out.println("You have exceeded the limit...");
System.exit(0);
}
System.out.println("Try Again...");

System.out.println("Username?");
u = input.next();
System.out.println("Password?");
p = input.next();
}
}
static void order(){
System.out.println("\tPrice And Products Lists:");
System.out.println("Barbeque: Php 20 \n"
+ "Grilled Hotdog: Php 15\n"
+ "Isaw: Php 13 \n"
+ "Dinuguan: Php 15");
System.out.println("\tChoose Your Product:");
System.out.println("Press BQ for Barbeque \n"
+ "GH for Grilled Hotdog \n"
+ "IS for Isaw \n"
+ "DG for Dinuguan");
item = input.next();
OUTER:
while (true) {
switch (item) {
case "BQ":
System.out.println("How many pieces?");
O = input.nextDouble();
P=20;
tP = 20*O;
item="Barbeque";
break OUTER;
case "GH":
System.out.println("How many pieces?");
O = input.nextDouble();
P=15;
tP = 15*O;
item ="Grill Hotdog";
break OUTER;
case "IS":
System.out.println("How many pieces?");
O = input.nextDouble();
P=13;
tP = 13*O;
item ="Isaw";
break OUTER;
case "DG":
System.out.println("How many pieces?");
O = input.nextDouble();
P=15;
tP = 15*O;
item ="Dinuguan";
break OUTER;
default:
System.out.println("This Is Not Listed In The Products Lists\
n"
+ "Please Try Again");
break;
}
}
while(true){
if(O<100){
System.out.println("No discount");
System.out.println("Pay the sum of amount: Php"+P);
break;
}
else if(O<300){
System.out.println("You have 5% discount");
DP=tP*(1- 0.05);
DA=P*O*0.05;
System.out.println("Pay this amount: Php"+DP);
break;
}
else if(O<600){
System.out.println("You have 15% discount");
DP=tP*(1- 0.15);
DA=P*O*0.15;
System.out.println("Pay this amount: Php"+DP);
break;
}
else if(O<1000){
System.out.println("You have 30% discount");
DP =tP*(1-0.30);
DA=P*O*0.30;
System.out.println("Pay for this amount: Php"+DP);
break;
}
else if(O>=1000){
System.out.println("You have 50% discount");
DP=tP*(1- 0.50);
DA=P*O*0.50;
System.out.println("Pay this amount: Php"+DP);
break;
}
else{
System.out.println("It is not a valid response");
}
}
System.out.println("We Have a Discount Lists That Shows You The Discount on
Your Order");
System.out.println("\tDiscount Lists:");
System.out.println("For Every < 100 Orders You'll Have No Discount");
System.out.println("For Every < 300 Orders You'll Have 5% Discount");
System.out.println("For Every < 600 Orders You'll Have 15% Discount");
System.out.println("For Every < 1000 Orders You'll Have 30% Discount");
System.out.println("For Every=> 1000 Orders You'll Have 50% Discount\n\n");
OUTER_1:
while (true) {
System.out.println("\tDo you wish to use our Delivery Serice? \n"
+ "(Type Y if Yes and N if No)");
DL=input.next();
switch (DL) {
case "N":
System.out.println("Do you rather prefer to pick it up? \n"
+ "(Type Y if Yes and N if No)");
PU = input.next();
if(PU.equals("Y")){
System.out.println("Pick Up is ofcourse Free of Charge");
DM = "PICK UP";
M = "N/A";
return;
}
else;
System.out.println("I Suggest To You TO Use Our Delivery
Service");
break;
case "Y":
System.out.println("Our Online Delivery Service will Cost You
Additional Charge");
System.out.println("For every <= 2km, You'll add Php 20");
System.out.println("For every <= 4km, You'll add Php 30");
System.out.println("For every <= 6km, You'll add Php 50");
System.out.println("6km and above is not in reach of our
delivery service \n"
+ "We Advised For You To Pick It Up Instead");
DM = "ONLINE DELIVERY";
break OUTER_1;
default:
System.out.println("It is not a Valid Response\n"
+ "Please Try Again");
break;
}
}
while(true){
System.out.println("How Many Kilometers Are Your Location From The
Store?");
D=input.nextInt();
if(D <= 2){
System.out.println("You'll Add Additional Php 20 for the Delivery
Fee");
DF = 20;
break;
}
else if(D <= 4){
System.out.println("You'll Add Additional Php 30 for the Delivery
Fee");
DF = 30;
break;
}
else if(D <= 6){
System.out.println("You'll Add Additional Php 50 for the Delivery
Fee");
DF = 50;
break;
}
else if(D >= 6){
System.out.println("Your Location Is Not Within Our Delivery
Service\n"
+ "We Suggests For You To Pick It Up Instead");
break;
}
else{
System.out.println("It is Not a Valid Responsen\n"
+ "Please Try Again");
}
}
}
static void summary(){
t = DF + DP;
System.out.println("*************************************");
System.out.println("SUMMARY TRANSACTION");
System.out.println("***************************************");
System.out.println("USERNAME: "+u);
System.out.println("ITEM NAME: "+item);
System.out.println("PRICE PER ITEM: "+P);
System.out.println("QUANTITY: "+ O);
System.out.println("DISCOUNT AMOUNT: "+DA);
System.out.println("DELIVERY MODE: "+DM);
System.out.println("DISTANCE: "+D);
System.out.println("DELIVERY CHARGE: "+DF);
System.out.println("Total Price: "+t);
}

You might also like