Question
eclipse java Oxygen
Design a self-service fast food menu. Name your class FastFood. Create a test class based on the examples from chapter 4. Cre
Thank you Operation The user enters a string value. The application prompts the user to input the quantity The application di
0 0
Add a comment Improve this question Transcribed image text
Answer #1

FastFood.java

package abcquestions;

public class FastFood {

   private String choice;
   private double total;
   private double price;
   private double subtotal;

   public FastFood() {
       super();
       this.total = 0;
       this.subtotal = 0;
       this.price = 0;

   }

   public String getChoice() {
       return choice;
   }

   public void setChoice(String choice) {
       this.choice = choice;
   }

   public double getTotal() {
       return total;
   }

   public void setTotal(double total) {

       this.total = this.total + total;
   }

   public double getPrice() {
       return price;
   }

   public void setPrice(double price) {
       this.price = price;
   }

   public double getSubtotal() {
       return subtotal;
   }

   public void setSubtotal(double subtotal) {
       this.subtotal = subtotal;
   }

}

TestFood.java

package abcquestions;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class TestFood {
   public static void main(String args[]) {
// Valid items for ordering
Map<String,Integer> items = new HashMap<>();
       items.put("CHICKEN", 5);
       items.put("FISH", 9);
       items.put("BURGER", 9);
      
       FastFood food = new FastFood();
      
       Scanner sc = new Scanner(System.in);
      
       String decision = "Y";
       System.out.println("Welcome to the fast food order menu\n How may i help you");
      
       while(decision.equalsIgnoreCase("Y")) {
           System.out.println("Please place your order:");
           food.setChoice(sc.nextLine());
           if(items.containsKey(food.getChoice().toUpperCase())) {
               System.out.println("Please place you quantity:");
               food.setPrice(items.get(food.getChoice().toUpperCase())* sc.nextInt());
               food.setSubtotal(food.getPrice());
               food.setTotal(food.getSubtotal());
               System.out.println("Your Order $"+food.getSubtotal());
               System.out.println("Your subtotal: $"+food.getTotal());
               System.out.println("Continue (y/n)"+sc.nextLine());
               decision = sc.nextLine();
           }else {
               System.out.println("Please place your order:");
               food.setSubtotal(food.getPrice());
               food.setTotal(food.getSubtotal());
               System.out.println("Your Order $"+food.getSubtotal());
               System.out.println("Your subtotal: $"+food.getTotal());
               System.out.println("Continue (y/n)");
               decision = sc.nextLine();
           }
          
       }
       System.out.println("Please pay for your order");
   }
}

Output:

Welcome to the fast food order menu
How may i help you
Please place your order:
HHHH
Please place your order:
Your Order $0.0
Your subtotal: $0.0
Continue (y/n)
Y
Please place your order:
CHICKEN
Please place you quantity:
6
Your Order $30.0
Your subtotal: $30.0
Continue (y/n)
y
Please place your order:
FISH
Please place you quantity:
10
Your Order $90.0
Your subtotal: $120.0
Continue (y/n)
Y
Please place your order:
BURGER
Please place you quantity:
10
Your Order $90.0
Your subtotal: $210.0
Continue (y/n)
N
Please pay for your order

Add a comment
Know the answer?
Add Answer to:
eclipse java Oxygen Design a self-service fast food menu. Name your class FastFood. Create a test...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a menu-driven Java application that solves several math problems. The user will select a number,...

    Create a menu-driven Java application that solves several math problems. The user will select a number, and the program will respond with a necessary data. When the user enters option 5, the program will end. Below is sample output for the program: What would you like me to do? 1. Calculate area of a circle? 2. Convert Fahrenheit temperature to Celsius? 3. Convert miles to kilometer? 4. Convert inches to centimeter? 5. Exit program? Please enter your option: 1 Enter...

  • Your assignment is to create a restaurant ordering system where the cashier can create the menu...

    Your assignment is to create a restaurant ordering system where the cashier can create the menu and then take in the order and display the order back to the customer Sample Execution – Level 1 Welcome to your Menu Creation system. How many items would you like to have on your menu? 2 Create your menu! Enter item #1: Coffee Enter item #2: Tea This is the menu: Coffee Tea What would you like to order? Cake That isn’t on...

  • Create a JAVA program for a Kiosk management system. A local kiosk in your neighborhood has...

    Create a JAVA program for a Kiosk management system. A local kiosk in your neighborhood has been heavily challenged by the manual system currently used to manage the kiosk’s day to day operations. The kiosk management have been informed of your newly acquired knowledge in application development and have approached you to create an electronic management system. The system is meant to help the Kiosk in managing its stock and finances; with this in mind your application should then offer...

  • I should use the array and loop to create a java program according to the instruction,...

    I should use the array and loop to create a java program according to the instruction, but I have no idea how to do it. Introduction This lab assignment continues to give you practice using loops, particularly loops with variable termination conditions, and it also provides you an opportunity to use one-dimensional arrays. Recall that an array is used to store a collection of data. The data can be values of Java primitive data types or else objects (for instance,...

  • JAVA Objective : • Learning how to write a simple class. • Learning how to use...

    JAVA Objective : • Learning how to write a simple class. • Learning how to use a prewritten class. • Understanding how object oriented design can aid program design by making it easier to incorporate independently designed pieces of code together into a single application. Instructions: • Create a project called Lab13 that contains three Java file called Book.java , Bookstore.java and TempleBookstore.java • I’ve provided a screenshot of how your project should look like. • Be sure to document...

  • Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class...

    Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...

  • Pop’s Pie Shop wants you to help computerize its ever-changing menu. Here’s an example of the...

    Pop’s Pie Shop wants you to help computerize its ever-changing menu. Here’s an example of the delicious items that Pop’s has to offer: Here is what we are starting with today: Savory: Savory Mince & Cheese Pork & Peach BBQ C urried Lamb & Spinach Chicken & Kumara Smoked Salmon, Leek & Potato Thai Butternut Curry (vegan) Sausage Roll Spinach & Cheese Roll Beef Pasty Sweet Pie by the slice: Banoffee Blueberry Apple (vegan) Buttermilk & Raspberry Chocolate Chess Chocolate...

  • Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one me...

    Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one menu item called Search. Clicking on search should prompt the user using a JOptionPane input dialog to enter a car make. The GUI should then display only cars of that make. You will need to write a second menu...

  • please help fill out the class menu create a prototype that will display information about housing...

    please help fill out the class menu create a prototype that will display information about housing data1. In this prototype you will use dynamic array data structures to store the data and compute metrics. For the requirements of the prototype, your client has given you a list of metrics and operations. The user interface will be a menu that displays this list and prompts the user to choose which option to execute.You will create two classes. First you will create...

  • Java Project In Brief... For this Java project, you will create a Java program for a...

    Java Project In Brief... For this Java project, you will create a Java program for a school. The purpose is to create a report containing one or more classrooms. For each classroom, the report will contain: I need a code that works, runs and the packages are working as well The room number of the classroom. The teacher and the subject assigned to the classroom. A list of students assigned to the classroom including their student id and final grade....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT