Overview
JAVA LANGUAGE PROBLEM:
The owner of a restaurant wants a program to manage online orders that come in. This program will require multiple classes. Summary class, customer class, order class and the driver class.
Summary class
This class will keep track of the cost of the order and output a summary, which includes the total for the order. The methods in this class are static. There are no instance variables, and instead uses an Order object that is passed in to the methods.
Order Class
This class will keep track of a persons order. It will also store the total number of orders made for the day, as well as the total amount collected for the day.
Customer class
This class will store the information needed to identify the customer who has placed the order.
Driver class
This class will present the user with menu options and then determine actions based on the user selections.
Instance variables:
Methods:
Main Method: You will use the main method to continually prompt the user for the startupMenu and then as long as the user does not choose to end the day, the user will be presented with a menu to place their order. You will need to continually display the menu until the user has finished the order, at which you will end the order and display the results.
All input must be validated to ensure that input is of the correct datatype, as well as in the correct range.
V
Sample Run #1:
Which do you want to do:
1- Begin the day
2- Continue
3- Close for the day
1
Welcome to SnackShack.
Choose the item you would like to order:
1-Burger - $5.00
2-Chicken Sandwich - $5.25
3-Taco - $2.00
4-Nachos - $6.50
5-Fries - $2.50
6-Drink
7-Finished with order
1
Burger - $5.00 each
How many do you want? 2
Choose your next item:
1-Burger - $5.00
2-Chicken Sandwich - $5.25
3-Taco - $2.00
4-Nachos - $6.50
5-Fries - $2.50
6-Drink
7-Finished with order
7
End of order
Is this for pickup or delivery?
1- Pickup
2- Delivery
1
One last thing! What should we call you? Tonya
And a phone number, just in case we have questions: 3094567890
Your order is:
Burgers: 2
Name: Tonya
Phone: 3094567890
Total for this order is:
Subtotal: $10.00
Tax: $ 0.70
Total: $10.70
Which do you want to do:
1- Begin the day
2- Continue
3- Close for the day
2
Total orders received today 1
Total amount collected today $10.70Welcome to SnackShack.
Choose the item you would like to order:
1-Burger - $5.00
2-Chicken Sandwich - $5.25
3-Taco - $2.00
4-Nachos - $6.50
5-Fries - $2.50
6-Drink
7-Finished with order
5
Fries - $2.50
How many do you want? 5
Choose your next item:
1-Burger - $5.00
2-Chicken Sandwich - $5.25
3-Taco - $2.00
4-Nachos - $6.50
5-Fries - $2.50
6-Drink
7-Finished with order
6
How many small drinks do you want? a
Invalid input. Please enter a number!
How many do you want? Invalid input. Please enter a number!
How many do you want? 3
How many medium drinks do you want?
2
How many large drinks do you want?
1
You requested the following drinks:
Large: 1
Medium: 2
Small: 3
Choose your next item:
1-Burger - $5.00
2-Chicken Sandwich - $5.25
3-Taco - $2.00
4-Nachos - $6.50
5-Fries - $2.50
6-Drink
7-Finished with order
7
End of order
Is this for pickup or delivery?
1- Pickup
2- Delivery
2
One last thing! What should we call you? Brian
Where should this be delivered? 123 Main St.
And a phone number, just in case we have questions: 3095678901
You can expect delivery in 52 minutes
Your order is:
Fries: 5
Small Drinks: 3
Medium Drinks: 2
Large Drinks: 1
Name: Brian
Address: 123 Main St.
Phone: 3095678901
Total for this order is:
Subtotal: $22.00
Tax: $ 1.54
Total: $23.54
Which do you want to do:
1- Begin the day
2- Continue
3- Close for the day
3
Total orders received today 2
Total amount collected today $34.24
Code:-
import java.util.Random;
import java.util.Scanner;
public class Main {
//Instance variables
public static Scanner s = new Scanner(System.in);
public static Order ord;
//This method receives order & customer object & show
their information
public static void outputResults(Order order, Customer
customer){
Summary s = new Summary();
s.calculateSubtotal(order);
s.calculateTax(order);
s.calculateTotal(order);
System.out.println(customer.toString()+"\n"+order.toString()+"\n"+"Order
Summary:"+s.outputSummary(ord));
}
//it receives an integer which will determine delivery choice 1
means yes , 0 (pickup) means no
public static void getCustomerInfo(int deliveryChoice, Order
order){
Customer c;
//If pickup
if(deliveryChoice == 0){
//collecting information from customer
System.out.print("\nEnter your name: ");
String name = s.next();
System.out.print("Enter your phone number: ");
String phoneNum = s.next();
//create a customer object with address null because he did not
request for delivery
c= new Customer(name, null, phoneNum);
}
else{
//If he wants delivery
//collecting information from customer
System.out.print("\nEnter your name: ");
String name = s.next();
System.out.print("Enter your phone number: ");
String phoneNum = s.next();
System.out.print("Enter your address: ");
String address = s.next();
c= new Customer(name , address , phoneNum);
//generate random number for delivery time
Random r= new Random();
System.out.println("The delivery time is "+(r.nextInt(60-30)+30)+"
minutes");
}
//Now showing output
outputResults(order, c);
}
//Will get the choice from user either delivery or pickup
public static int determineDelivery(){
System.out.println("\nPress '0' for pickup");
System.out.println("Press '1' for Delivery");
int opt = s.nextInt();
return opt;
}
public static void displayMenu(){
Scanner s = new Scanner(System.in);
System.out.println("\n1.Burger");
System.out.println("2.Fries");
System.out.println("3.Taco");
System.out.println("4.Nachos");
System.out.println("5.Chicken Sandwiches");
System.out.print("\nHow many Burgers: ");
int burger = s.nextInt();
System.out.print("How many Fries: ");
int fries = s.nextInt();
System.out.print("How many Tacos: ");
int tacos = s.nextInt();
System.out.print("How many Nachos: ");
int nachos = s.nextInt();
System.out.print("How many Chicken Sandwiches: ");
int csandwich = s.nextInt();
//Default keep no delivery
Boolean isDeliver = false;
int deliver=determineDelivery();
//If he wants means presses '1', he wants delivery
if(deliver == 1){
isDeliver = true;
}
//Creating an Order object
ord = new Order(burger, fries, tacos, nachos, csandwich, 0, 0,
0,isDeliver);
//get customer Info & showing result
getCustomerInfo(deliver, ord);
}
public static void drinkMenu(){
System.out.println("\n1.Small Drinks");
System.out.println("2.Medium Drinks");
System.out.println("3.Large Drinks");
System.out.print("How many small drinks: ");
int small = s.nextInt();
System.out.print("How many medium drinks: ");
int medium = s.nextInt();
System.out.print("How many large drinks: ");
int large = s.nextInt();
//Default keep no delivery
Boolean isDeliver = false;
int deliver=determineDelivery();
//If he wants means presses '1', he wants delivery
if(deliver == 1){
isDeliver = true;
}
ord = new Order(0, 0 ,0 ,0, 0, small, medium , large,
isDeliver);
//get customer Info & showing result
getCustomerInfo(deliver, ord);
}
//outputs total number of orders
public static void endOfDay(Order order){
System.out.println("\nNumber of Orders at end of the day:
"+order.getNo_of_orders());
}
public static void startupMenu(){
//showing menu until user has not selected for end of day
Scanner s = new Scanner(System.in);
int opt=0;
while (!(opt==3)){
System.out.println("\n1.Eatable Menu");
System.out.println("2.Drink Menu");
System.out.println("3.End of Day");
opt = s.nextInt();
if(opt == 1){
displayMenu();
}
else if(opt == 2){
drinkMenu();
}
else if(opt == 3){
endOfDay(ord);
}
else{
System.out.println("Invalid option");
}
}
}
public static void main(String[] args) {
System.out.println("\n\t\t\t----------------------Menu-----------------------------");
//Just call Startup Menu
startupMenu();
}
}
class Customer{
//Instance variables
private String fullName;
private String address;
private String phoneNum;
//Constructor
public Customer(String fullName, String address, String
phoneNum) {
this.fullName = fullName;
this.address = address;
this.phoneNum = phoneNum;
}
//Getter & setters
public String getFullName() {
return fullName;
}
public String getAddress() {
return address;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public void setAddress(String address) {
this.address = address;
}
//toString method that would show name & phone number and address only if it is not null
@Override
public String toString() {
if(!(address == null)){
//If address is not null, return the address also
return "\n\nCustomer Name: "+fullName+"\n"+"Address:
"+address+"\n"+"Phone num: "+phoneNum;
}
else{
return "\n\nCustomer Name: "+fullName+"\n"+"Phone num:
"+phoneNum;
}
}
}
class Order{
//Defining constants
private static final double burgerPrice = 5.0;
private static final double friesPrice = 2.50;
private static final double tacoPrice = 2.0;
private static final double nachosPrice = 6.50;
private static final double chickenSandwichPrice = 5.25;
private static final double smallDrinkPrice = 1.25;
private static final double mediumDrinkPrice = 1.75;
private static final double largeDrinkPrice = 2.25;
//Instance variables----
private int no_of_Burgers;
private int no_of_Fries;
private int no_of_Tacos;
private int no_of_Nachos;
private int no_of_ChickenSandwiches;
private int no_of_SmallDrinks;
private int no_of_MediumDrinks;
private int no_of_LargeDrinks;
Boolean isDelivery;
//static variables
private static int no_of_orders;
private static double total_dollar_amount;
//Constructor
public Order(){
//increment count of each item by 1
no_of_Burgers++;
no_of_Fries++;
no_of_Tacos++;
no_of_Nachos++;
no_of_ChickenSandwiches++;
no_of_SmallDrinks++;
no_of_MediumDrinks++;
no_of_LargeDrinks++;
no_of_orders++;
}
//Custom Constructor
public Order(int no_of_Burgers, int no_of_Fries, int no_of_Tacos, int no_of_Nachos, int no_of_ChickenSandwiches, int no_of_SmallDrinks, int no_of_MediumDrinks, int no_of_LargeDrinks, Boolean isDelivery) {
this();
this.no_of_Burgers = no_of_Burgers;
this.no_of_Fries = no_of_Fries;
this.no_of_Tacos = no_of_Tacos;
this.no_of_Nachos = no_of_Nachos;
this.no_of_ChickenSandwiches = no_of_ChickenSandwiches;
this.no_of_SmallDrinks = no_of_SmallDrinks;
this.no_of_MediumDrinks = no_of_MediumDrinks;
this.no_of_LargeDrinks = no_of_LargeDrinks;
this.isDelivery = isDelivery;
}
//Setters & Getters for all instance variables
public static double getBurgerPrice() {
return burgerPrice;
}
public static double getFriesPrice() {
return friesPrice;
}
public static double getTacoPrice() {
return tacoPrice;
}
public static double getNachosPrice() {
return nachosPrice;
}
public static double getChickenSandwichPrice() {
return chickenSandwichPrice;
}
public static double getSmallDrinkPrice() {
return smallDrinkPrice;
}
public static double getMediumDrinkPrice() {
return mediumDrinkPrice;
}
public static double getLargeDrinkPrice() {
return largeDrinkPrice;
}
public int getNo_of_Burgers() {
return no_of_Burgers;
}
public void setNo_of_Burgers(int no_of_Burgers) {
this.no_of_Burgers = no_of_Burgers;
}
public int getNo_of_Fries() {
return no_of_Fries;
}
public void setNo_of_Fries(int no_of_Fries) {
this.no_of_Fries = no_of_Fries;
}
public int getNo_of_Tacos() {
return no_of_Tacos;
}
public void setNo_of_Tacos(int no_of_Tacos) {
this.no_of_Tacos = no_of_Tacos;
}
public int getNo_of_Nachos() {
return no_of_Nachos;
}
public void setNo_of_Nachos(int no_of_Nachos) {
this.no_of_Nachos = no_of_Nachos;
}
public int getNo_of_ChickenSandwiches() {
return no_of_ChickenSandwiches;
}
public void setNo_of_ChickenSandwiches(int
no_of_ChickenSandwiches) {
this.no_of_ChickenSandwiches = no_of_ChickenSandwiches;
}
public int getNo_of_SmallDrinks() {
return no_of_SmallDrinks;
}
public void setNo_of_SmallDrinks(int no_of_SmallDrinks) {
this.no_of_SmallDrinks = no_of_SmallDrinks;
}
public int getNo_of_MediumDrinks() {
return no_of_MediumDrinks;
}
public void setNo_of_MediumDrinks(int no_of_MediumDrinks)
{
this.no_of_MediumDrinks = no_of_MediumDrinks;
}
public int getNo_of_LargeDrinks() {
return no_of_LargeDrinks;
}
public void setNo_of_LargeDrinks(int no_of_LargeDrinks) {
this.no_of_LargeDrinks = no_of_LargeDrinks;
}
public Boolean getDelivery() {
return isDelivery;
}
public void setDelivery(Boolean delivery) {
isDelivery = delivery;
}
public static int getNo_of_orders() {
return no_of_orders;
}
public static void setNo_of_orders(int no_of_orders) {
Order.no_of_orders = no_of_orders;
}
public static double getTotal_dollar_amount() {
return total_dollar_amount;
}
public static void setTotal_dollar_amount(double
total_dollar_amount) {
Order.total_dollar_amount = total_dollar_amount;
}
@Override
public String toString() {
//If any eatable is empty, just show drinks
if(no_of_Burgers == 0){
return "\nOrder\n"+"No of Small Drinks: "+no_of_SmallDrinks+
"\nNo of Medium Drinks: "+no_of_MediumDrinks+
"\nNo of Large Drinks: "+no_of_LargeDrinks+"\n";
}
else{
return "\nOrder:" +
"\nno_of_Burgers=" + no_of_Burgers +
"\nno_of_Fries=" + no_of_Fries +
"\nno_of_Tacos=" + no_of_Tacos +
"\nno_of_Nachos=" + no_of_Nachos +
"\nno_of_ChickenSandwiches=" + no_of_ChickenSandwiches+"\n";
}
}
}
class Summary{
//Constants
private static final double taxRate = 0.07;
private static final double deliveryCharge = 3.00;
private static final double minimumOrder = 20.0;
//Methods
public double calculateSubtotal(Order o){
//We would determine subtotal by multiplying the cost of each item by the count of that item
return (o.getBurgerPrice()*o.getNo_of_Burgers()) +
(o.getFriesPrice()*o.getNo_of_Fries()) +
(o.getTacoPrice()*o.getNo_of_Tacos())
+(o.getNachosPrice()*o.getNo_of_Nachos()) +
(o.getChickenSandwichPrice()*o.getNo_of_ChickenSandwiches())
+(o.getSmallDrinkPrice()*o.getNo_of_SmallDrinks()) +
(o.getMediumDrinkPrice()*o.getNo_of_MediumDrinks()) +
(o.getLargeDrinkPrice()*o.getNo_of_LargeDrinks());
}
public double calculateTax(Order o){
//It will call the calculateSubtotal method and then multiply the tax rate by the total returned from that method
return calculateSubtotal(o)*taxRate;
}
public double calculateDeliveryCharge(Order o){
//check if that customer is requested for delivery, if so show
the charge of delivery
//Also check if the order is less than minimum order
if(o.getDelivery() && calculateSubtotal(o) <
minimumOrder){
return deliveryCharge;
}
else{
return 0;
}
}
public double calculateTotal(Order order){
//calculate total by adding subtotal , tax and corresponding delivery charges
return calculateSubtotal(order) + calculateTax(order) +
calculateDeliveryCharge(order);
}
public String outputSummary(Order o){
return "\nSubtotal: $"+ calculateSubtotal(o)
+"\n"+"Tax: $"+calculateTax(o)
+"\n"+"Delivery Charges: $"+calculateDeliveryCharge(o)
+"\n"+"Total Price: $"+calculateTotal(o)+"\n\n";
}
}
Output Screenshots:-



Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders...
Using C++ Mr. Manager wants you to process orders for the Fast Greasy Food Shop. His customers have a few choices in what they order. The can order a hamburger for 1.00. It they want cheese it is an addition .50 and if they want bacon the additional amount is .75. They can also order a small or large drink for 1.10 and 1.60 respectively and small or large French fries for 1.20 or 1.75 respectively. The user can only...
Order up:: Write a program that will be used to keep track of orders placed at a donut shop. There are two types of items that can be ordered: coffee or donuts. Your program will have a class for each order type, and an abstract superclass. Coffee orders are constructed with the following information: quantity (int) - how many coffees are being ordered size (String) - the size of the coffees (all coffees in the order have the same size)...
Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's best friend owns a restaurant. That person is very bad at math and recently discovered that most customers have been significantly undercharged for meals. You have been approached to create a computer program that will accurately calculate bills for each customer. Kids, under 5, eat free. Teens and seniors get a 25% discount. Also, Food and beverage is taxed at 5%. No tax for anything...
Please write this code in JAVA lang., thank you! Your spouse's cousin's nephew's dog's trainer's best friend owns a restaurant. That person is very bad at math and recently discovered that most customers have been significantly undercharged for meals. You have been approached to create a computer program that will accurately calculate bills for each customer. Kids, under 5, eat free. Teens and seniors get a 25% discount. Also, Food and beverage is taxed at 5%. No tax for anything...
The code snippet below is part of the restaurant menu program you previously used in the lab. Add a choice for a drink. Add the necessary code to allow the program to calculate the total price of order for the user. Assume the following price list: Hamburger $5 Hotdog $4 Fries $3 Drink $2 The program should allow the user to keep entering order until choosing to exit. At the end the program prints an order summary like this: You...
JAVA Problem: Coffee Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public void prepare (); } The prepare method will...
JAVA Problem: Coffee do not use ArrayList or Case Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public void prepare ();...
Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type(does not mention the data type of the variable coffeeType), price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public...
(2 bookmarks) In JAVA You have been asked to write a program that can manage candidates for an upcoming election. This program needs to allow the user to enter candidates and then record votes as they come in and then calculate results and determine the winner. This program will have three classes: Candidate, Results and ElectionApp Candidate Class: This class records the information for each candidate that is running for office. Instance variables: first name last name office they are...
Project overview: Create a java graphics program that displays an order menu and bill from a Sandwich shop, or any other establishment you prefer. In this program the design is left up to the programmer however good object oriented design is required. Below are two images that should be used to assist in development of your program. Items are selected on the Order Calculator and the Message window that displays the Subtotal, Tax and Total is displayed when the Calculate...