Question: Can someone please help me solve this getter and setter Java program? Thank you! Create and test a Beer class: Define a Beer class that
Can someone please help me solve this getter and setter Java program? Thank you!
Create and test a Beer class: Define a Beer class that contains the following private instance variables, both having accessors and mutators (getters and setters): String name; // the beers name and double alcohol; // the alcohol %, eg, .05 for 5%
Also add the following method to calculate the number of 12 ounce drinks of beer required for a person of a given weight to become intoxicated at .08 blood alcohol this is the only method needed beyond the getters and setters:
public double intoxicated(double weight) { double numDrinks; // this is a simplification of the // Widmark formula numDrinks = (0.08 + 0.015) * weight / (12 * 7.5 * alcohol); return numDrinks; }
Write code in a main method that creates two Beer objects with different alcohol percentages. For each Beer object, invoke (call) the intoxicated() method for a light individual and a heavy individual and output the estimated number of drinks for them to become legally intoxicated. Light could mean 100 pounds, heavy 200 pounds, but you should choose those values.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
