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

Program Requirements Modify the program you wrote for Java Assn 3, as follows: O

ID: 3889513 • Letter: P

Question

Program Requirements
Modify the program you wrote for Java Assn 3, as follows:

Overview of Program This program will contain two classes, in two separate files within your project A new Drinker class to define the data fields and methods for a Drinker object, containing * o Five data field (attribute) definitions for a Drinker object O A constructor method to create a Drinker obiect o Five setter methods to set the values for all of the data fields o Three getter methods to get the values of two of the data fields o An instance method to compute the volume distribution for men o An instance method to compute the volume distribution for women o An instance method to compute and display the current BAC. The main BACcalculator class, modified to define only 3 methods, containing * o A main method to display the program description, create an object, read the inputs from the user, and call the other methods o A static method to display a description of what the program will do o A static method to display drinker's information Since there will be multiple files, the program will be submitted via a .zip file (see last page)

Explanation / Answer

package javapractice;

import java.util.Scanner;

public class Drinker {

private String drinkerIdentifier;

private double weight;

private double height;

private int drinksComsumed;

private int elapsedTime;

Scanner sc=new Scanner(System.in);

public Drinker() {

drinkerIdentifier = "";

weight = 0.0;

height = 0.0;

drinksComsumed = 0;

elapsedTime = 0;

}

public String getDrinkerIdentifier() {

return drinkerIdentifier;

}

public void setDrinkerIdentifier(String lastName,String phoneNumber) {

lastName=lastName.toUpperCase();

drinkerIdentifier = lastName.substring(0, 3)+phoneNumber.substring(phoneNumber.length()-5,phoneNumber.length()-1);

}

public double getWeight() {

return weight;

}

public void setWeight(double weightInPounds) {

double numberOfPoundsForKG=2.20462;

weight=weightInPounds/numberOfPoundsForKG;

}

public double getHeight() {

return height;

}

public void setHeight(double heightInInch) {

double numberOfInchInMeter=39.3701;

height = heightInInch*numberOfInchInMeter;

}

public int getDrinksComsumed() {

return drinksComsumed;

}

public void setDrinksComsumed() {

System.out.println("Enter the number of drinks consumed");

drinksComsumed=sc.nextInt();

}

public int getElapsedTime() {

return elapsedTime;

}

public void setElapsedTime() {

System.out.println("Enter the number of hours passed while drinking");

elapsedTime=sc.nextInt();

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote