Question

You are going to write a java application that will be used in a coffee shop...

You are going to write a java application that will be used in a coffee shop to take customer orders and print a simple on screen order summary. Your coffee shop only sells one type and one size coffee for $5 dollars. However, your customers have the option of adding whipped cream and chocolate each for $1 dollar.

Your application takes in customer name, the number of coffees being ordered and whether or not the customer wants whipped cream and/or chocolate on them. It provides a live update of the total price based on customer order and once the order is placed it will provide the customer with an order summary.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CoffeePay.java

import java.util.Scanner;

public class CoffeePay {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("Enter the customer name: ");

String name = scan.next();

System.out.println("Enter the number of coffees being ordered: ");

int n = scan.nextInt();

boolean cream[] = new boolean[n];

boolean chocolate[] = new boolean[n];

int total = 0;

for(int i=0;i<n;i++){

total = total + 5;

System.out.println("Enter create to be added to the coffee "+(i+1)+": ");

cream[i] = scan.nextBoolean();

if(cream[i]) {

total = total + 1;

}

System.out.println("Enter chocolate to be added to the coffee "+(i+1)+": ");

chocolate[i] = scan.nextBoolean();

if(chocolate[i]) {

total = total + 1;

}

System.out.println("Total Price: "+total);

}

int price = 0;

System.out.println("\tCustomer "+name+" Summary");

System.out.println("Order\t\tCream\tChocolate\tPrice");

for(int i=0; i<n;i++) {

price = 5;

if(cream[i]) price++;

if(chocolate[i]) price++;

System.out.printf("%s %10s %10s %10s\n","Coffee"+(i+1),cream[i],chocolate[i],price );

}

System.out.println("Total Price: "+total);

}

}

Output:

Enter the customer name:

Suresh

Enter the number of coffees being ordered:

2

Enter create to be added to the coffee 1:

true

Enter chocolate to be added to the coffee 1:

false

Total Price: 6

Enter create to be added to the coffee 2:

true

Enter chocolate to be added to the coffee 2:

true

Total Price: 13

Customer Suresh Summary

Order Cream Chocolate Price

Coffee1 true false 6

Coffee2 true true 7

Total Price: 13

Add a comment
Know the answer?
Add Answer to:
You are going to write a java application that will be used in a coffee shop...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Order up:: Write a program that will be used to keep track of orders placed at...

    Order up:: Write a program that will be used to keep track of orders placed at a donut shop. There are two types of items that can be ordered: coffee or donuts. Your program will have a class for each order type, and an abstract superclass. Coffee orders are constructed with the following information: quantity (int) - how many coffees are being ordered size (String) - the size of the coffees (all coffees in the order have the same size)...

  • The CQ EMBA Bagel and Coffee Shop carries Gimme!’s freshly roasted coffee. The Kingston branch has...

    The CQ EMBA Bagel and Coffee Shop carries Gimme!’s freshly roasted coffee. The Kingston branch has the coffee shipped over from Ithaca. There is a fixed fee of $30 for each shipment of coffee. Gimme! charges the Bagel and Coffee Shop $12/pound for the coffee and the Bagel and Coffee Shop uses a 20% interest rate for holding cost. The Kingston branch uses 20 pounds of coffee per day with a standard deviation of 4 pounds per day. The lead...

  • Java: Write an Applet Application to create a menu for a pizza shop. Use check boxes,...

    Java: Write an Applet Application to create a menu for a pizza shop. Use check boxes, radio buttons, and a JButton to allow a customer to make selections and process their order. Use a text area to display the customer's order and the amount due.

  • Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to...

    Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to complete a partially completed Java program. The program should either print the name and price for a coffee add-in from the Jumpin’ Jive coffee shop or it should print the message: "Sorry, we do not carry that.". Read the problem description carefully before you begin. The data file provided for this lab includes the necessary variable declarations and input statements. You need to write...

  • Suppose that the amount of service(ordering a coffee and getting it done) time at a KU driving- through coffee shop is exponentially distributed with an expected value of 10 minutes. You arrive at th...

    Suppose that the amount of service(ordering a coffee and getting it done) time at a KU driving- through coffee shop is exponentially distributed with an expected value of 10 minutes. You arrive at the driving-through line while one customer is being served and one other customer is waiting in the line. The staff of the coffee shop informs you that the customer has already ordered a Cafe Latte and waited for 5 minutes. What is the probability that the customer...

  • You own a local coffee shop and your senior barista, whom everyone loves and has been...

    You own a local coffee shop and your senior barista, whom everyone loves and has been with you for 6 years, just informed you that she will be leaving soon as she has decided to move to a different city.   You are considering hiring a junior person and training them as a barista knowing that they will make mistakes on customer orders, or you can hire an experienced barista at a higher wage that has a great resume and references.  ...

  • Assignment 1. You are to write a simple program using Netbeans Java IDE  that consists of two...

    Assignment 1. You are to write a simple program using Netbeans Java IDE  that consists of two classes. The program will allow the user to place an order for a Tesla Model X car. 2. Present the user with a menu selection for each option on the site. We will use JOptionPane to generate different options for the user. See the examples posted for how to use JOPtionPane. 3. Each menu will have multiple items each item will be in the...

  • Pop’s Pie Shop wants you to help computerize its ever-changing menu. Here’s an example of the...

    Pop’s Pie Shop wants you to help computerize its ever-changing menu. Here’s an example of the delicious items that Pop’s has to offer: Here is what we are starting with today: Savory: Savory Mince & Cheese Pork & Peach BBQ C urried Lamb & Spinach Chicken & Kumara Smoked Salmon, Leek & Potato Thai Butternut Curry (vegan) Sausage Roll Spinach & Cheese Roll Beef Pasty Sweet Pie by the slice: Banoffee Blueberry Apple (vegan) Buttermilk & Raspberry Chocolate Chess Chocolate...

  • Java Concurrency! You have been given a simple API to buy and print postage. Write a...

    Java Concurrency! You have been given a simple API to buy and print postage. Write a program that submits each incoming order to the API and then prints the shipping label. Unfortunately each call to the shipping label API is SLOW… To compensate for this, use concurrency so that your program can be making several calls to the API at one time. We also need to keep track of our expenses, so make sure to calculate how much money is...

  • Sample Execution – Level 3 Welcome to your Menu Creation system. How many items would you...

    Sample Execution – Level 3 Welcome to your Menu Creation system. How many items would you like to have on your menu? 2 Create your menu! Enter item #1: Coffee Enter the number of toppings: 2 Enter topping #1: Whipped Cream Enter topping #2: Cinnamon Enter item #2: Tea Enter the number of toppings: 2 Enter topping #1: Milk Enter topping #2: Sugar May I take your order? This is the menu: Coffee Tea Pop How many items would you...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT