Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is a workaholic?

Answered: 1 week ago

Question

3. Identify the four major structures that compose a neuron.

Answered: 1 week ago

Question

Define induction and what are its objectives ?

Answered: 1 week ago

Question

Discuss the techniques of job analysis.

Answered: 1 week ago

Question

How do we do subnetting in IPv6?Explain with a suitable example.

Answered: 1 week ago

Question

Explain the guideline for job description.

Answered: 1 week ago

Question

What is job description ? State the uses of job description.

Answered: 1 week ago

Question

1. Discuss the four components of language.

Answered: 1 week ago

Question

f. What stereotypes were reinforced in the commercials?

Answered: 1 week ago