Question
Can you please compile this code or let me know about the errors in the code // CoffeeShop.java import java.util.Scanner; public class CoffeeShop { public
Can you please compile this code or let me know about the errors in the code
// CoffeeShop.java
import java.util.Scanner;
public class CoffeeShop {
public static void main(String[] args) { final double COFFEE = 3.80; String addons[] = { "Whipped Cream", "Cinnamon", "Chocolate sauce", "Amaretto", "Irish Whiskey" }; double prices[] = { 0.89, 0.25, 0.59, 1.50, .75 }; String selectedAddons[]=new String[10]; double selectedprices[]=new double[10]; double totPrice=0.0; int cnt=0;
/* * Creating an Scanner class object which is used to get the inputs * entered by the user */ Scanner sc = new Scanner(System.in);
System.out.println("WELCOME TO THE BRISTO's COFFEE SHOP "); totPrice+=COFFEE; while(true) { // Getting the input entered by the user System.out.println(" Id\tProduct\t\t\tPrice($)"); System.out.println("--\t-------\t\t\t--------"); for (int i = 0; i < addons.length; i++) { System.out.printf("%-4d%-28s%.2f ",(i+1), addons[i], prices[i]); } System.out.print("Enter Choice (-1 to exit):"); int choice=sc.nextInt(); if(choice==-1) { break; } else if(choice<1 || choice>addons.length) { System.out.println("** Invalid Choice **"); } else if(choice!=-1) { totPrice+=prices[choice-1]; selectedAddons[cnt]=addons[choice-1]; selectedprices[cnt]=prices[choice-1]; cnt++; } }
System.out.println(); System.out.println(" BRISTO's COFFEE SHOP"); System.out.printf("%-20s$%.2f ","Coffee : ",COFFEE); for(int i=0;i }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started