I need help with a programming project. Here are the instructions: (75 points) P
ID: 3707907 • Letter: I
Question
I need help with a programming project. Here are the instructions:
(75 points) Program runs successfully
(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
(25 points) Program contents follow readability standards including:
(15 points) Correct use of ArrayList<Beverage> lists
(10 points) Successfully complete simple and detailed format methods in Beverage class
Summary
We will create a detailed EBAC (Estimated Blood Alcohol Content) Tracker. Along with sobriety, we will also track calorie content and cost data to better help the user choose their drinks for the night. This data varies greatly based on the location, venue, and bartender, but very rough estimates are provided for the purpose of this project.
Details
Your program will need to start by asking the user for their weight to the nearest pound, then ask them to input each drink they have. These drinks are defined below, and you must use these items in the exactly the same order, though you can add items at the end of the list if desired. We will use standard values for the rest of the items required in the formula and assume that all drinks are consumed at the same time for simplicity. When the user enters -1 for their drink choice you will print a final summary that includes: 1) Every drink they had that night with its detailed summary (alcohol content, calories, and cost), 2) Their bill for the night 3) Their total calories consumed, 4) Their final EBAC, and 5) How long until they are complete sober again. Below is a sample run of the program, with the user input in green/bold/underlined format. To complete this project, you are required to use ArrayLists and the Beverage object that I provided for you. (This means you may NOT use primitive arrays.)
Note: When I test your projects, I will always enter valid data, but I will not enter the exact values from below. I will alter the weight, number of drinks, and drink selections to fully test your program.
Welcome to the EBAC Calculator!
Please enter your weight to the nearest pound:
150
Please enter the number of the item you would like to drink: (-1 to exit)
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)
1
Please enter the number of the item you would like to drink: (-1 to exit)
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)
2
Please enter the number of the item you would like to drink: (-1 to exit)
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)
9
Please enter the number of the item you would like to drink: (-1 to exit)
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)
4
Please enter the number of the item you would like to drink: (-1 to exit)
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)
-1
Final Summary
You had the following drinks tonight:
Cosmopolitan 2.0 oz 212 cal $7.0
Gin and Tonic 2.0 oz 175 cal $6.0
Water 0.0 oz 0 cal $0.0
Margarita 2.5 oz 153 cal $7.5
Your bill for the night is: $20.5
You have consumed 540 calories.
Your final EBAC is 0.3181904761904762
It will be 6.5 hours until you are sober again
Good night!
Required Values
The formula for EBAC that we will use is: ouncesOfAlcohol * 5.14 / (weight * 0.7). Since we are using 1 ounce/hour as an estimate for alcohol processing, the ouncesOfAlcohol value is also the hours until the user is sober again.
Here are the drinks that you will need to use in your program, in this order. Notice that the first drink starts at 0. You may add additional drinks starting at index 10 if desired.
Index
Name
Ounces of Alcohol
Calories
Cost
0
Bourbon and Water
2
140
6.00
1
Cosmopolitan
2
212
7.00
2
Gin and Tonic
2
175
6.00
3
Mojito
2
242
6.00
4
Margarita
2.5
153
7.50
5
Martini
2.5
127
7.00
6
Pina Colada
3
440
6.00
7
Screwdriver
2
181
7.00
8
Vodka and Tonic
2
200
6.00
9
Water
0
0
0
Programming Strategy
As always, there are two big items to tackle in this project: Logic (how to hold all of this information in an ArrayList of Beverages) and Syntax (how to write all of the method calls, etc). It is very important that you think ahead to keep the logic clear, and then work each complex line of code methodically to get all of the syntax details in shape. Specifically: Remember that you will have an ArrayList of Beverage objects. When you use the get method on that ArrayList you will have an instance of a Beverage object, and from there you can make all of the necessary gets/sets/etc on the Beverage object.
Source Code Management
I strongly recommend the use of a Source Code Management product like git or svn that allows you to save your work periodically and then go back and look at the previous iterations. This allows you to “go back” if you break something and gives you confidence to improve already working code. Just be sure if you use an external site, like GitHub, that you create a private repository so others cannot view your code. Using an SCM will not give you any points for this assignment, but it may very well save you from getting a 0 if your program breaks at the last minute.
Index
Name
Ounces of Alcohol
Calories
Cost
0
Bourbon and Water
2
140
6.00
1
Cosmopolitan
2
212
7.00
2
Gin and Tonic
2
175
6.00
3
Mojito
2
242
6.00
4
Margarita
2.5
153
7.50
5
Martini
2.5
127
7.00
6
Pina Colada
3
440
6.00
7
Screwdriver
2
181
7.00
8
Vodka and Tonic
2
200
6.00
9
Water
0
0
0
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.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.