Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Description Your assignment is to write a program called CoffeeShop (in the file

ID: 441047 • Letter: D

Question

Description Your assignment is to write a program called CoffeeShop (in the file CoffeeShop.java) that simulates a virtual coffee shop, allowing the user to select an item to purchase, along with the quantity of that item. After obtaining the item selection and desired quantity from the user, your program should calculate the cost, tax, discount, and final cost, then display these to the user. Program Requirements Your program must run as follows: a. Prompt the user for his/her name. Read the user

Explanation / Answer

import java.util.Scanner; public class CoffeeDriver { //main method public static void main (String[] args){ String[] itemName = {"Coffee, Water, Milk, Donut, Bagel"}; double[] itemPrice = {1.00, 2.00, 1.50, 0.75, 1.25}; Scanner input = new Scanner(System.in); String decision; System.out.println ("Welcome to Wings Coffee Shop"); System.out.println ("We have a great list of tasty items on our menu."); System.out.println ("Would you like to see these items sorted by"); System.out.println ("name or by price? (n/p): "); decision = input.nextLine(); if (decision == "n"){ sortName(itemName); } else { sortPrice(itemPrice); } } //method to sort by item name and display public static void sortName (String[] array){ for (int i = 0; i