77.5k views
3 votes
Write a program that will allow you to do the following

1. Adds food.
- A list of available foods will be displayed to the user with their prices.
-Ask the user to enter the name of the food.
-Next, ask the user the quantity of this food they would like to get.
-From the given item, calculate the sub total of the selected food they added.
-Display the menu again.
2. View order
-The users current cart total and number of items will be displayed.
3. Clear order
-The user will be able to clear their cart. However, before clearing the cart, give the following message to the user: do you want to clear your cart?
-If the user enters yes, clear the cart. In other words, "CART" should be blank. If the user enters no, display "Cart not changed. Going back to menu."
-Display the menu again.
4. Checkout
-The user will be able to view the number of items and their total (including tax 7.25%).
-Ask the user to select pickup or delivery. If the user selects delivery, add a $5.00 delivery fee to the total and continue and ask for an address. If the user selects pickup, just continue.
-Ask the user to enter their 16-digit card number to complete the order.
-Print out their receipt which should include:
-The number of items they purchased.
-Their total
-Terminate the program.
5.Exit
-Tell the user "Thank you for using our app Goodbye!" and terminate the program.
The following code has to be using Scanner and else if statements, there cant be any libraries

User Molavec
by
7.9k points

1 Answer

4 votes

Final answer:

The student is tasked with creating a Java program for a food ordering system using the Scanner for input and else if statements for control flow, without external libraries. The program should include functionality for adding food items, viewing and clearing the cart, checking out with tax and delivery fees, and exiting the program.

Step-by-step explanation:

Implementation of a Food Ordering Program

The task is to create a food ordering program that allows a user to perform various functions such as adding food to the cart, viewing the order, clearing the order, checking out, and exiting the program. The program is expected to handle user inputs for the food item and quantity, calculate subtotals, manage cart content, and finalize the order with a payment process. The checkout process includes a tax calculation and an additional fee for delivery. Throughout the implementation, the Scanner class will be used to accept user input, and else if statements will be utilized for control flow. It is important to note that the use of external libraries is not permitted in the coding of this program.

An example implementation in Java could include a main menu loop with options to add food, view order, clear order, checkout, and exit. A switch statement would handle the navigation based on the user's choice. Additional functions such as calculating tax, adding a delivery fee, and processing the user's card number could also be part of the program.

User Etienne De Martel
by
8.3k points