QuestionQuestion

Update the class LemonadeStand from your assignment to include the following:

1. Change the price per glass of lemonade to a constant variable.
Also be sure to rename the variable to show the proper naming convention for constant variables. [1 point]

2. Using a switch statement: [2 points]

If the payment type is C or c, then display "Credit card transaction" on the screen
If the payment type is D or d, then display "Debit card transaction" on the screen
If the payment type is M or m, then display "Money transaction" on the screen
If the payment type is V or v, then display "Venmo transaction" on the screen
If the payment is none of the above, then display "Invalid payment type" on the screen, and end the program with System.exit(1);
3. Using a single if-else-if statement: [3 points]

If the user paid via credit card or debit card, then charge a $0.50 credit/debit fee. Add that fee to the total, and display the new total on the screen.
If the user paid via money (cash) and the total is $5 or more, then give a 10% discount. If the total is less than $5, then no discount will be given. Subtract that discount from the total, and display that new total on the screen.
If the user paid via Venmo and the total is more than $10, then tell the user they earned a free glass of lemonade
Example Output (user input is in green)

Welcome to the Lemonade Stand, what is your name?

Amanda

Hi Amanda, how many glasses of lemonade would you like? They are $1.75 each

2

Each glass costs $1.75, so the total due is $3.50.

How will you be paying today?

C

Credit card transaction.

There will be a $0.50 fee for using Credit Card. Your new total is $4.00. Thanks and have a nice day!

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.Scanner;
import java.text.DecimalFormat;

public class LemonadeStand {
   
    // 1. Change the price per glass of lemonade to a constant variable.
    //    Also be sure to rename the variable to show the proper naming convention for constant variables.
    public static final double PRICE_PER_GLASS_OF_LEMONADE = 1.75;
   
    static Scanner key = new Scanner(System.in);
   
    public static void main (String [] args){
      
       Scanner scnr = new Scanner(System.in);
       String name;
       char payment;
      
       int numCup;
       double totalCost;
      
       System.out.println("Hello and welcome to my Lemonade...

By purchasing this solution you'll be able to access the following files:
LemonadeStand.java.

$30.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats