Results 1 to 6 of 6
  1. #1
    plnstrk2 is offline Member
    Join Date
    Dec 2013
    Posts
    2
    Rep Power
    0

    Default Java Homework Help! Need done by midnight

    Hey guys, I have java homework due tonight and I have almost no idea of what to do. The instructions provided are below, my teacher also gave us the code that we have to place in 3 different classes, ill post the instructions then the code below them. Please give me a beginner lvl idea of what to do. I know I should know this by now but i kinda started slacking mid semester and got too lost to catch up. Thanks so much for helping sorry that the threads so long.


    INSTRUCTIONS.INSTRUCTIONS.INSTRUCTIONS.INSTRUCTION S.INSTRUCTIONS.


    Create project BAC_OOP_YOURNAME

    Create three classes

    Person
    BAC_Test
    BAC_OOP with a main


    Follow the code contained within the class printout.txtPreview the documentView in a new window



    BAC_OOP

    Example one

    person class with name Jane, Doe, female, 130 pounds

    a hospital/clinic would take the person's name, then a second person would run the test.

    So person would be defined and instantiated long before being called this way.

    The police do this all at once, information and test quickly.

    BAC_Test PatSmithTest = new BAC_Test(4, 3.00, "Pat", "Smith", "Male", 180.00);

    PRT("");

    PRT(PatSmithTest.getDrinker().getFullName());

    PRT(PatSmithTest.AlcoholContent());



    Person JaneDoe = new Person("Jane", "Doe", "Female", 123.00);

    BAC_Test JaneDoeTest = new BAC_Test(4, 5.00, JaneDoe);

    PRT(JaneDoeTest.AlcoholContent());

    PRT(JaneDoe.toString() );







    build a loop which ends with an end loop flag (do while loop)

    ask for the person information

    test for BAC passing your person instance into the new BAC instance.

    repeat the person's toString and BAC result from the toString



    Person

    Person class is a generic class describing a person. It tracks a person’s name, gender, height and weight.

    BAC_Test

    Calculate the BAC

    ToString() = First Name, Last Name, BAC Level, should they be driving message, height and weight.



    Measuring BAC

    Typically, this is what will occur at each BAC level:

    .01-.06

    - Feeling of Relaxation

    - Sense of Well-Being

    - Thought, Judgment and Coordination are Impaired



    .06-.10

    - Loss of Inhibitions

    - Extroversion

    - Reflexes, Depth Perception, Peripheral Vision and Reasoning are Impaired



    .11-.20

    - Emotional Swings

    - Sense of Sadness or Anger

    - Reaction Time and Speech are Impaired



    .21-.29

    - Stupor

    - Blackouts

    - Motor Skills are Impaired



    .30-.39

    - Severe Depression

    - Unconsciousness

    - Breathing and Heart Rate are Impaired



    >.40

    - Breathing and Heart Rate are Impaired

    - Death is Possible

    Blood / Breath Alcohol Concentration (BAC) calculator - WisDOT javascript taken.

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    CODE.CODE.CODE.CODE.CODE.CODE.CODE.CODE


    /**
    * Measuring BAC
    * Typically, this is what will occur at each BAC level:
    * .01-.06
    * - Feeling of Relaxation
    * - Sense of Well-Being
    * - Thought, Judgment and Coordination are Impaired
    *
    * .06-.10
    * - Loss of Inhibitions
    * - Extroversion
    * - Reflexes, Depth Perception, Peripheral Vision and Reasoning are Impaired
    *
    * .11-.20
    * - Emotional Swings
    * - Sense of Sadness or Anger
    * - Reaction Time and Speech are Impaired
    *
    * .21-.29
    * - Stupor
    * - Blackouts
    * - Motor Skills are Impaired
    *
    * .30-.39
    * - Severe Depression
    * - Unconsciousness
    * - Breathing and Heart Rate are Impaired
    *
    * >.40
    * - Breathing and Heart Rate are Impaired
    * - Death is Possible
    * Blood / Breath Alcohol Concentration (BAC) calculator - WisDOT javascript taken.
    *
    */

    /**
    * @author Jeff Fisher
    *
    */
    public class BAC_Test {
    private double genderValue;
    private int drinkNumber;
    private double hoursDrinking;
    private Person drinker;

    /**
    * @param drinkNumber
    * @param hoursDrinking
    * @param drinker
    */
    public BAC_Test( int DrinksNumber, double HoursDrinking, Person aDrinker)
    {
    this.drinkNumber = DrinksNumber;
    this.hoursDrinking = HoursDrinking;
    this.drinker = aDrinker;
    }

    /**
    * @param genderValue
    * @param drinkNumber
    * @param hoursDrinking
    * @param drinker
    */
    public BAC_Test(int drinkNumber, double hoursDrinking,
    String FirstName, String LastName, String Gender, double Weight) {
    this.drinkNumber = drinkNumber;
    this.hoursDrinking = hoursDrinking;
    this.drinker = new Person(FirstName,LastName,Gender,Weight);
    }


    /**
    * @return the genderValue
    */
    public double getGenderValue() {
    return genderValue;
    }
    /**
    * @param genderValue the genderValue to set
    */
    public void setGenderValue(double genderValue) {
    this.genderValue = genderValue;
    }
    /**
    * @return the drinkNumber
    */
    public int getDrinkNumber() {
    return drinkNumber;
    }
    /**
    * @param drinkNumber the drinkNumber to set
    */
    public void setDrinkNumber(int drinkNumber) {
    this.drinkNumber = drinkNumber;
    }
    /**
    * @return the hoursDrinking
    */
    public double getHoursDrinking() {
    return hoursDrinking;
    }
    /**
    * @param hoursDrinking the hoursDrinking to set
    */
    public void setHoursDrinking(double HoursDrinking) {
    this.hoursDrinking = HoursDrinking;
    }
    /**
    * @return the drinker
    */
    public Person getDrinker() {
    return drinker;
    }
    /**
    * @param drinker the drinker to set
    */
    public void setDrinker(Person drinker) {
    this.drinker = drinker;
    }

    /*
    * set the gender value based on the gender of the
    */
    private void setGenderValue(){
    if (this.drinker.getGender().toUpperCase().equals("MA LE"))
    this.genderValue =0.58;
    else
    this.genderValue = 0.49;

    }

    /**
    * If all attributes completed BAC can be calculated.
    */
    private double CalculateBAC(){
    double alcohol = this.drinkNumber*.045;
    double metabolism = this.hoursDrinking*.012;
    double numWeight = this.drinker.getWeight() /2.2046;

    setGenderValue();

    double numWater = numWeight * this.genderValue * 1000;
    double oz = 23.36 / numWater;
    double bac0 = oz *0.806;
    bac0 *=1000;
    double bac1 = bac0*alcohol;
    double BAC = bac1-metabolism;

    if (BAC < 0)
    {
    BAC = 0.000;
    }

    return BAC;
    }

    /*
    * produce a string answer stating the blood alcohol content.
    */
    public String AlcoholContent()
    {
    double BACresult = CalculateBAC();
    String Result;
    String BAC = String.format("%.2f", BACresult);
    if (BACresult >= 0.08){
    Result= "Your BAC is at " + BAC + " you are beyond the legal limit.";
    }

    else if ((BACresult >= 0.06) && (BACresult < 0.08))
    {
    Result = "Your BAC is at " + BAC + " you are close the legal limit.\n Please be very careful driving.";
    }
    else if ((BACresult >= 0.01) && (BACresult < 0.06))
    {
    Result = "Your BAC is at " + BAC + ".\n Please be careful driving.";
    }
    else
    Result = "Please be careful driving and sorry for the interruption.";

    return Result;
    }

    /*
    * (non-Javadoc)
    * @see java.lang.Object#toString()
    * Create a toString given information we discussed
    */
    public String toString(){

    return "Use field data";
    }
    }
    // ================================================== ================================================== ==============
    /*
    * Person class is a generic class describing a person
    *
    * Jeffrey A. Fisher
    */
    public class Person {
    private String firstName;
    private String lastName;
    private String gender;
    private double height;
    private double weight;

    /**
    * @param firstName
    * @param lastName
    * @param sexType
    */
    public Person(String FirstName, String LastName, String sex) {
    this.firstName = FirstName;
    this.lastName = LastName;
    gender = sex;
    height = 0.00;
    weight = 0.00;
    }
    /**
    * @param firstName
    * @param lastName
    * @param sexType
    * @param weight
    */
    public Person(String FirstName, String LastName, String sex,
    double Weight) {
    this.firstName = FirstName;
    this.lastName = LastName;
    gender = sex;
    height = 0.00;

    if (Weight < 0.00)
    this.weight = 0.00;
    else
    this.weight = Weight;
    }

    /**
    * Copy one Person into an other
    */
    public Person(Person Object2){
    firstName = Object2.firstName;
    lastName = Object2.lastName;
    gender = Object2.gender;
    weight = Object2.weight;
    height = Object2.height;
    }


    /**
    * @return the fullName
    */
    public String getFullName() {
    return firstName + " " + lastName;
    }


    /**
    * @return the firstName
    */
    public String getFirstName() {
    return firstName;
    }
    /**
    * @param firstName the firstName to set
    */
    public void setFirstName(String FirstName) {
    this.firstName = FirstName;
    }
    /**
    * @return the lastName
    */
    public String getLastName() {
    return lastName;
    }
    /**
    * @param lastName the lastName to set
    */
    public void setLastName(String LastName) {
    this.lastName = LastName;
    }
    /**
    * @return the sexType
    */
    public String getGender() {
    return gender;
    }
    /**
    * @return the height
    */
    public double getHeight() {
    return height;
    }
    /**
    * @param height the height to set
    */
    public void setHeight(double Height) {
    this.height = Height;
    }
    /**
    * @return the weight
    */
    public double getWeight() {
    return weight;
    }
    /**
    * @param weight the weight to set
    */
    public void setWeight(double Weight) {
    this.weight = Weight;
    }
    /**
    * return
    */
    public String toString(){
    String message = this.getFullName() + " is a " + this.getGender();

    if (this.height > 0.00f)
    {
    if(this.getGender().toUpperCase() == "FEMALE") // correct this line of code
    message += ", she is " + this.getHeight() + " tall";
    else
    message += ", he is " + this.getHeight() + " tall";
    }
    if (this.weight > 0.00f)
    message += " and wieghts " + this.getWeight() + " pounds";

    message += ".";
    return message;
    }
    public boolean equals(Person object2){
    boolean status = false;

    return status;
    }
    }
    // ================================================== =====================================
    /**
    * BAC
    * This project records a person and determines their blood alcohol content level
    */

    /**
    * @author Jeff Fisher
    *
    */
    public class BAC_OOP {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    // Example one
    // person class with name Jane, Doe, female, 130 pounds
    // a hospital/clinic would take the person's name, then a second person would run the test.
    // So person would be defined and instantiated long before being called this way.
    // The police do this all at once, information and test quickly.
    BAC_Test PatSmithTest = new BAC_Test(4, 3.00, "Pat", "Smith", "Male", 180.00);
    PRT("");
    PRT(PatSmithTest.getDrinker().getFullName());
    PRT(PatSmithTest.AlcoholContent());

    Person JaneDoe = new Person("Jane", "Doe", "Female", 123.00);
    BAC_Test JaneDoeTest = new BAC_Test(4, 5.00, JaneDoe);
    PRT(JaneDoeTest.AlcoholContent());
    PRT(JaneDoe.toString() );



    // build a loop which ends with an end loop flag (do while loop)
    // ask for the person information
    // test for BAC passing your person instance into the new BAC instance.
    // repeat the person's toString and BAC result from the toString
    }

    /*
    * my favorite function
    * a simple println function
    */
    public static void PRT(String message){
    System.out.println(message);
    }
    }

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default Re: Java Homework Help! Need done by midnight

    Please post the code you are having problems with and ask some specific questions about your problems.

    Be sure to wrap your code with code tags:
    [code]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    I think you've waited too long to be able to get this working by midnight.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    plnstrk2 is offline Member
    Join Date
    Dec 2013
    Posts
    2
    Rep Power
    0

    Default Re: Java Homework Help! Need done by midnight

    Quote Originally Posted by Norm View Post
    Please post the code you are having problems with and ask some specific questions about your problems.

    Be sure to wrap your code with code tags:
    [code]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    I think you've waited too long to be able to get this working by midnight.
    Hey thanks for the reply, the whole code is above and i dont have a problem with it, my teacher gave me these instructions:
    // build a loop which ends with an end loop flag (do while loop)
    // ask for the person information
    // test for BAC passing your person instance into the new BAC instance.
    // repeat the person's toString and BAC result from the toString

    The code itself has to go in three separate classes (Person, BAC_Test, BAC_OOP)
    From the instructions can you help me understand what i have to do with the code given?
    Refer to my first post for more info in the code comments.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default Re: Java Homework Help! Need done by midnight

    What specific questions do you have? Just posting the assignment doesn't tell me what problems you have with it.

    Please edit your post and wrap your code with code tags:
    [code]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,608
    Rep Power
    5

    Default Re: Java Homework Help! Need done by midnight

    So you refer someone to a site the specializes in helping others cheat. And it even tailors the code to fit their experience level. How sad.
    Fortunately, this is 4 months late.
    Last edited by jim829; 03-31-2014 at 09:23 PM.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  6. #6
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    946
    Rep Power
    2

    Default Re: Java Homework Help! Need done by midnight

    Reported.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

Similar Threads

  1. Java Homework Help Please!
    By xletmelive267x in forum New To Java
    Replies: 1
    Last Post: 04-15-2013, 04:36 AM
  2. Java Homework Help!
    By ajb5876 in forum New To Java
    Replies: 16
    Last Post: 02-13-2013, 11:08 AM
  3. Home work help due midnight
    By alucard in forum New To Java
    Replies: 2
    Last Post: 03-29-2010, 04:09 AM
  4. LF: Homework help with Java
    By excurssion in forum New To Java
    Replies: 2
    Last Post: 10-17-2008, 06:00 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •