Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For Java CoffeeShop Test CoffeeShop Modify the coffee shop program Add code that allows multiple customers This will require a loop Also, each customer can

For Java

image text in transcribed

CoffeeShop

image text in transcribed

Test CoffeeShop

image text in transcribed

Modify the coffee shop program Add code that allows multiple customers This will require a loop Also, each customer can buy regular coffee, latte, or espresso Again, customers can buy multiple cups However, all cups must be the same type You should have different prices for the different types of drinks Your submission should consist of a test class as well as the coffee shop class Create methods as appropriate. Use good design principles: Ask the customer the various questions Avoid excessive questions and options Make sure you follow basic coding principles Comment each method and other parts of the code, as you think it's appropriate public class Coffee Shop { double total; // A variable to hold the amount the customer owes /** A method to calculate a customer's bill. The amount owed is stored in the variable total. @param numCups The number of cups of coffee the customer ordered +/ void calcBill (int numCups) final double cupCost = 2.35 The cost of a single cup of coffee final double taxRate = 0.09, 11 The current tax rate double subtotal, salesTax; 1/ Calculate the subtotal subtotal = cupCost numCups; 11 Calculate the sales tax salesTax = taxRace subtotal, // Calculate the full price total = subtotal + salesTax, 3 /** Return the amount owed by the customer @returns The amount the customer owes double getBill) return total; 3 } import java.util.Scanner; public class TestCoffeeShop { public static void main (String [] args) { Scanner input = new Scanner (System.in); CoffeeShop myCoffeeShop = new CoffeeShop(); System.out.print ("How many cups of coffee would you like? "); int cupsofCoffee input.nextInt(); myCoffeeshop.calcBill(cupsofCoffee); System.out.printf ("You owe $%.2f", myCoffeeShop.getBill(); } }

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

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

Students also viewed these Databases questions

Question

Explain the solution.

Answered: 1 week ago

Question

=+ Are there closed-shop requirements or practices?

Answered: 1 week ago