Question

In: Computer Science

Using JAVA The Jumpin' Jive coffee shop charges $2 for a cup of coffee and offers...

Using JAVA
The Jumpin' Jive coffee shop charges $2 for a cup of coffee and offers the add-ins shown in Table 6-2. Design the logic for an application that allows a user to enter ordered add-ins continuously until a sentinel value is entered. After each item, display its price or the message Sorry, we do not carry

//that as output. After all items have been entered, display the total price for the order.



whipper cream 0.89
cinnamon 0.25
chocolate sauce 0.59
amaretto 1.50
irish whiskey 1.75

Solutions

Expert Solution

Explanation:I have written the code as mentioned and have also shown the output by using the main method, please find the image attached with the answer.Please upvote if you liked my answer and comment if you need any modification or explanation.

//code

import java.util.Scanner;

public class JumpinJiveCoffeeShop {

   public static void main(String[] args) {
       Scanner input = new Scanner(System.in);
       float[] addinsPrice = {0.89f, 0.25f, 0.59f, 1.50f, 1.75f};
       int choice = 0;
       float totalPrice = 2;
       while (true) {
           System.out.print("Welcome to Jumpin'Jive coffee shop:\n"
                   + "1)whipper cream \n" + "2)cinnamon\n"
                   + "3)chocolate sauce\n" + "4)amaretto\n"
                   + "5)irish whiskey\n" + "-1)Exit\n"
                   + "please select a choice:");
           choice = input.nextInt();
           if (choice == -1)
               break;
           switch (choice) {
               case 1 :
                   System.out.println("whisper cream "
                           + addinsPrice[choice - 1] + " added");
                   totalPrice += addinsPrice[choice - 1];
                   break;
               case 2 :
                   System.out.println(
                           "cinnamom " + addinsPrice[choice - 1] + " added");
                   totalPrice += addinsPrice[choice - 1];
                   break;
               case 3 :
                   System.out.println("chocolate sauce "
                           + addinsPrice[choice - 1] + " added");
                   totalPrice += addinsPrice[choice - 1];
                   break;
               case 4 :
                   System.out.println("Sorr, we do not carry amaretto.");
                   break;
               case 5 :
                   System.out.println("irish whiskey "
                           + addinsPrice[choice - 1] + " added");
                   totalPrice += addinsPrice[choice - 1];
                   break;
               case 6 :
                   break;
           }
       }

       System.out.println("The total price for the order is "
               + Math.round(totalPrice * 100.0) / 100.0);
       input.close();

   }

}

Output:


Related Solutions

At a certain coffee​ shop, all the customers buy a cup of coffee and some also...
At a certain coffee​ shop, all the customers buy a cup of coffee and some also buy a doughnut. The shop owner believes that the number of cups he sells each day is normally distributed with a mean of 330 cups and a standard deviation of 23 cups. He also believes that the number of doughnuts he sells each day is independent of the coffee sales and is normally distributed with a mean of 170 doughnuts and a standard deviation...
At a certain coffee​ shop, all the customers buy a cup of coffee and some also...
At a certain coffee​ shop, all the customers buy a cup of coffee and some also buy a doughnut. The shop owner believes that the number of cups he sells each day is normally distributed with a mean of 340 cups and a standard deviation of 18 cups. He also believes that the number of doughnuts he sells each day is independent of the coffee sales and is normally distributed with a mean of 180 doughnuts and a standard deviation...
Question 16 The customers at Peete's coffee shop want to grab a quick cup of coffee...
Question 16 The customers at Peete's coffee shop want to grab a quick cup of coffee before boarding the Metra train into Chicago. The sign in the window promises "Quick, In-and-Out Service," and usually Peete's Coffee Shop keeps that promise. But one morning, customers were frustrated when the staff behind the counter showed more interest in gossiping about their social lives than in waiting on customers. Peete's coffee shop is suffering from a ________ gap.                 knowledge                 social expectations...
You may purchase a cup of coffee at a coffee shop, pay your telephone bill, purchase...
You may purchase a cup of coffee at a coffee shop, pay your telephone bill, purchase stamps at the post office, or so forth. In many cases, the transaction is documented using a point-of-sale system. Using the Internet, find the definition of a point-of-sale system and read about the controls that have been established by the University of Toronto (Links to an external site.)Links to an external site. related to these systems to answer the following question: What is a...
Your local coffee shop charges $0.75 per ounce of coffee, and you devote at most $25...
Your local coffee shop charges $0.75 per ounce of coffee, and you devote at most $25 per week for coffee. (a) Graph your budget constraint. (b) What is the opportunity cost of coffee? (c) Your coffee shop has some left over holiday coffee that it wants to get rid of. It decides to charge $0.50 per ounce for coffee beyond 7 ounces. Graph your new budget constraint. Please help with a, b and c
A car shop charges a battery using a current of 10 A for 2 hours. How...
A car shop charges a battery using a current of 10 A for 2 hours. How much charge passes through the battery? How many electrons pass through the battery in 1.5 hours
Scenario A: If the price of coffee went from $2/cup to $4/cup, and you reduced your...
Scenario A: If the price of coffee went from $2/cup to $4/cup, and you reduced your consumption from 100 cups/month to 90 cups/month, what is the elasticity of demand? Scenario B:  If the price of coffee went from $2/cup to $4/cup, and you reduced your consumption from 100 cups/month to 40 cups/month, what is the elasticity of demand? Which scenario shows elastic demand and which shows inelastic demand?
A person eats a grapefruit and drinks a large cup of coffee AND a cup of...
A person eats a grapefruit and drinks a large cup of coffee AND a cup of orange juice for breakfast (I guess they were thirsty). All these items are acidic! How will the respiratory and renal systems respond? Include a description of how the respiratory system detects the error signal and activates its response.
Trying to complete this in Java. Application called 'Coffee Shop' that uses a while loop to...
Trying to complete this in Java. Application called 'Coffee Shop' that uses a while loop to build a customer order. The Coffee Shops sells: Coffee ($3.25), Espresso ($4.25), and Tea ($2.75). The coffee selection presents the customer with the choices of iced (no charge), cream (50 cents), and sugar (50 cents). The espresso selection presents the customer with choice of caramel (no charge) and chocolate (no charge) with one shot (no charge) or two shots ($1.25) of espresso. Once the...
The Reader family owns a small neighborhood book store with a coffee shop/browsing area that offers...
The Reader family owns a small neighborhood book store with a coffee shop/browsing area that offers free Internet access to its customers. Their data infrastructure includes sufficient computing resources to support their business operations. Describe the Reader family’s computing needs and their possible need for client/server, intranet, and/or cloud computing that would support his business operations. Short Essay Question
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT