Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java: Beverage Class: Example of code: Learning Objectives 1. (75 points) Pro

ID: 3705753 • Letter: I

Question

In Java:

Beverage Class:

Example of code:

Learning Objectives 1. (75 points) Program runs successfully a. b. c. d. e. (10 points) Inputs weight from the user using a Scanner object. (5 points) Outputs all drink options in simple format (10 points) Inputs drink choices from the user using a Scanner object (5 points) Repeats until-1 is entered (45 points) Outputs the final summary correctly i. ii. iii. iv. v. List of drinks in detail format Bill for the night Calories consumed EBAC Time to sober 2. (25 points) Program contents follow readability standards including: (15 points) Correct use of ArrayList lists (10 points) Successfully complete simple and detailed format methods in Beverage class a. b.

Explanation / Answer

import java.util.*;
class Beverage
{

public String toString()
{

return " "+name+" "+alcoholContent +" oz "+calorieCount+" calories "+ "$"+cost;
}

private String name;
private double alcoholContent;
private int calorieCount;
private double cost;
public Beverage()
{
name = "Water";
alcoholContent = 0;
calorieCount = 0;
cost = 0.0;

}
public Beverage(String name,double alcoholContent,int calorieCount,double cost)
{
this.name = name;
this.alcoholContent = alcoholContent;
this.calorieCount = calorieCount;
this.cost = cost;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public double getAlcoholContent()
{
return alcoholContent;
}
public void setAlcoholContent(double alcoholContent)
{
this.alcoholContent = alcoholContent;
}
public int getCalorieCount()
{
return calorieCount;
}
public void setCalorieCount(int calorieCount)
{
this.calorieCount = calorieCount;
}
public double getCost()
{
return cost;
}
public void setCost(double cost)
{
this.cost = cost;
}
}
class TestBeverage
{
public static void main (String[] args)
{
Scanner input = new Scanner(System.in);

double totalPrice = 0;
int totalCalories = 0;
double totalAlcohol = 0;
System.out.println("Welcome to the EBAC Calculator");


System.out.println("Please enter your weight to the nearest pound : ");
int weight = input.nextInt();
int option = 10;
do
{

System.out.println("Please enter the number of item you would like to drink : (-1 to exit)");
System.out.println("0)Bourbon and Water ($6.0)");
System.out.println("1)Cosmopolitan ($7.0)");
System.out.println("2)Gin and Tonic ($6.0)");
System.out.println("3)Mojito ($6.0)");
System.out.println("4)Margarita ($7.5)");
System.out.println("5)Martini ($7.0)");
System.out.println("6)Pina Colada ($6.0)");
System.out.println("7)Screwdriver ($7.0)");
System.out.println("8)Vodka and Tonic ($6.0)");
System.out.println("9)Water ($0.0)");

option = input.nextInt();
if(option == -1)
break;
switch(option)
{
case 0: Beverage bourbonWater = new Beverage("Bourbon and Water",0.0,200,6.0);
    System.out.println(bourbonWater);
    totalPrice += 6.0;
    totalCalories += 200;
    totalAlcohol += 0.0;
   
    break;
case 1: Beverage cosmopolitan = new Beverage("Cosmopolitan",2.0,212,7.0);
    System.out.println(cosmopolitan);
    totalPrice += 7.0;
    totalCalories += 212;
    totalAlcohol += 2.0;
    break;
case 2: Beverage ginTonic = new Beverage("Gin and Tonic",2.0,175,6.0);
    System.out.println(ginTonic);
    totalPrice += 6.0;
    totalCalories += 175;
    totalAlcohol += 2.0;
    break;
case 3: Beverage mojito = new Beverage("Mojito",2.0,240,6.0);
    System.out.println(mojito);
    totalPrice += 6.0;
    totalCalories += 240;
    totalAlcohol += 2.0;
    break;
case 4: Beverage margarita = new Beverage("margarita",2.5,153,7.5);
    System.out.println(margarita);
    totalPrice += 7.5;
    totalCalories += 153;
    totalAlcohol += 2.5;
  
    break;
case 5: Beverage martini = new Beverage("Martini",0.0,230,7.0);
    System.out.println(martini);
    totalPrice += 7.0;
    totalCalories += 230;
    break;
case 6: Beverage pinaColada = new Beverage("Pina Colada",0.0,200,6.0);
    System.out.println(pinaColada);
    totalPrice += 6.0;
    totalCalories += 200;
    totalAlcohol += 0.0;
    break;
case 7: Beverage screwDriver = new Beverage("ScrewDriver",2.0,211,7.0);
    System.out.println(screwDriver);
    totalPrice += 7.0;
    totalCalories += 211;
    totalAlcohol += 2.0;
    break;
case 8: Beverage vodkaTonic = new Beverage("Vodka and Tonic",3.0,270,6.0);
    System.out.println(vodkaTonic);
    totalPrice += 6.0;
    totalCalories += 270;
    totalAlcohol += 3.0;
    break;
case 9: Beverage water = new Beverage("Water",0.0,0,0.0);
    System.out.println(water);
    totalPrice += 0.0;
    totalCalories += 0;
    totalAlcohol += 0.0;
   
    break;
default: System.out.println("Invalid option");
    break;
}
}while(option != -1);


System.out.println("Your bill for the night is : $"+totalPrice);
System.out.println("You have consumed "+totalCalories +" calories");
System.out.println("Your final EBAC is "+ totalAlcohol/weight);
System.out.println("It will be 6.5 hours until you are sober again");
System.out.println("Good Night ");
}
}

Output:

Welcome to the EBAC Calculator
Please enter your weight to the nearest pound :150
Please enter the number of item you would like to drink : (-1 to exit)1
0)Bourbon and Water ($6.0)
1)Cosmopolitan ($7.0)
2)Gin and Tonic ($6.0)
3)Mojito ($6.0)
4)Margarita ($7.5)
5)Martini ($7.0)
6)Pina Colada ($6.0)
7)Screwdriver ($7.0)
8)Vodka and Tonic ($6.0)
9)Water ($0.0)

Cosmopolitan 2.0 oz 212 calories $7.0
Please enter the number of item you would like to drink : (-1 to exit)2
0)Bourbon and Water ($6.0)
1)Cosmopolitan ($7.0)
2)Gin and Tonic ($6.0)
3)Mojito ($6.0)
4)Margarita ($7.5)
5)Martini ($7.0)
6)Pina Colada ($6.0)
7)Screwdriver ($7.0)
8)Vodka and Tonic ($6.0)
9)Water ($0.0)

Gin and Tonic 2.0 oz 175 calories $6.0
Please enter the number of item you would like to drink : (-1 to exit)9
0)Bourbon and Water ($6.0)
1)Cosmopolitan ($7.0)
2)Gin and Tonic ($6.0)
3)Mojito ($6.0)
4)Margarita ($7.5)
5)Martini ($7.0)
6)Pina Colada ($6.0)
7)Screwdriver ($7.0)
8)Vodka and Tonic ($6.0)
9)Water ($0.0)

Water 0.0 oz 0 calories $0.0
Please enter the number of item you would like to drink : (-1 to exit)4
0)Bourbon and Water ($6.0)
1)Cosmopolitan ($7.0)
2)Gin and Tonic ($6.0)
3)Mojito ($6.0)
4)Margarita ($7.5)
5)Martini ($7.0)
6)Pina Colada ($6.0)
7)Screwdriver ($7.0)
8)Vodka and Tonic ($6.0)
9)Water ($0.0)

margarita 2.5 oz 153 calories $7.5
Please enter the number of item you would like to drink : (-1 to exit)-1
0)Bourbon and Water ($6.0)
1)Cosmopolitan ($7.0)
2)Gin and Tonic ($6.0)
3)Mojito ($6.0)
4)Margarita ($7.5)
5)Martini ($7.0)
6)Pina Colada ($6.0)
7)Screwdriver ($7.0)
8)Vodka and Tonic ($6.0)
9)Water ($0.0)
Your bill for the night is : $20.5
You have consumed 540 calories
Your final EBAC is 0.043333333333333335
It will be 6.5 hours until you are sober again
Good Night

Do ask if any doubt. Please upvote.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote