Menu

Please Compile Code Let Know Errors Code Coffeeshopjava Import Javautilscanner Public Clas Q43854286

Can you please compile this code or let me know about the errorsin the code

// CoffeeShop.java

import java.util.Scanner;

public class CoffeeShop {

   public static void main(String[] args) {
       final double COFFEE = 3.80;
       String addons[] = { “WhippedCream”, “Cinnamon”, “Chocolate sauce”,
              “Amaretto”, “Irish Whiskey” };
       double prices[] = { 0.89, 0.25,0.59, 1.50, .75 };
       String selectedAddons[]=newString[10];
       double selectedprices[]=newdouble[10];
       double totPrice=0.0;
       int cnt=0;

       /*
       * Creating an Scanner class objectwhich is used to get the inputs
       * entered by the user
       */
       Scanner sc = newScanner(System.in);

       System.out.println(“WELCOME TOTHE BRISTO’s COFFEE SHOPn”);
      
       totPrice+=COFFEE;
       while(true)
       {
           // Getting theinput entered by the user
          System.out.println(“nIdtProducttttPrice($)”);
          System.out.println(“–t——-ttt——–“);
          
           for (int i = 0;i < addons.length; i++) {
              System.out.printf(“%-4d%-28s%.2fn”,(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(“** InvalidChoice **”);
   }
   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(“nnBRISTO’sCOFFEE SHOP”);
      System.out.printf(“%-20s$%.2fn”,”Coffee : “,COFFEE);
       for(int i=0;i<cnt;i++)
       {
          System.out.printf(“%-20s$%.2fn”,selectedAddons[i],selectedprices[i]);
       }
      System.out.printf(“—————————————–n”);
      System.out.printf(“%-20s$%.2fn”,”Total Price “,totPrice);
      System.out.printf(“—————————————–n”);
      
      
   }

}

Expert Answer


Answer to Can you please compile this code or let me know about the errors in the code // CoffeeShop.java import java.util.Scanner…

OR