SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 314 Weeks Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 08 Nov 2017 My Price 10.00

new assignment need me to alter the calculator and add some objects.

Hi! I really need help with this assignment. The other day you created a calc which i attached but the new assignment need me to alter the calculator and add some objects. I attached the requirements. Please help,

Thanks.
import java.util.Scanner;

public class BACcalculator {

    public static void main(String[] args) {

        // Defines constants for each item       
        final double POUNDS_PER_KILO = 2.20462;
        final double INCHES_PER_METER = 39.3701;
        final double MALE_META_RATE = 0.015;
        final double FEMALE_META_RATE = 0.014;

        // Calls method 1 (reads description to user)
        description();

        // Begins prompting user for input
        Scanner input = new Scanner(System.in);
        System.out.print("Please enter drinker's height (in inches): ");
        int heightInches = input.nextInt();
        System.out.print("Please enter the drinker's weight (in pounds): ");
        int weightPounds = input.nextInt();
        System.out.print("How many drinks were consumed? ");
        int drinksConsumed = input.nextInt();
        System.out.print("How many whole hours have elapsed since drinking "
                + "began? ");
        int hoursDrinking = input.nextInt();

        // Converts inches to meters and pounds to kilos
        double heightMeters = heightInches / INCHES_PER_METER;
        double weightKilos = weightPounds / POUNDS_PER_KILO;

        // Storing return values from methods 2 & 3
        double maleVAD = maleVAD(weightKilos, heightMeters);
        double femaleVAD = femaleVAD(weightKilos, heightMeters);

        // Calls current BAC for males from method 4
        double maleBAC = BAC(weightPounds, maleVAD, MALE_META_RATE,
                drinksConsumed, hoursDrinking);

        // Calls current BAC for females from method 4
        double femaleBAC = BAC(weightPounds, femaleVAD, FEMALE_META_RATE,
                drinksConsumed, hoursDrinking);

        // Prints results from method 5
        getResults(drinksConsumed, hoursDrinking, maleBAC, femaleBAC);

    }

    /**
     * Method 1 - This method will display a description to the reader of what
     * the program will do
     */
    public static void description() {
        System.out.println("This program implements a Blood Alcohol Conent "
                + "(BAC) Calculator\n");
        System.out.println("Given a drinker's weight and height, and the number"
                + " of drinks \nconsumed over how many hours, it will compute"
                + " the person's \napproximate current blood alcohol content\n");
    }

    /**
     * Method 2 - This method will calculate the volume distribution of alcohol
     * in the body for Men
     *
     * @param weightKilos, Weight in kilograms
     * @param heightMeters, Height in meters
     * @return the value for the Male Volume Distribution formula
     */
    public static double maleVAD(double weightKilos, double heightMeters) {
        double A = 0.012127;
        double B = 1.0178;
        double hSquared  = Math.pow(heightMeters, 2);
        double maleVolume = (B - (A * weightKilos) / hSquared);
        return maleVolume;
    }

    /**
     * Method 3 - This method will calculate the volume distribution of alcohol
     * in the body for Women
     *
     * @param weightKilos Weight in kilograms
     * @param heightMeters Height in meters
     * @return femaleVolume Value for the Female Volume Distribution formula
     */
    public static double femaleVAD(double weightKilos, double heightMeters) {
        final double A = 0.0124;
        final double B = 0.8736;
        double hSquared = Math.pow(heightMeters, 2);
        double femaleVolume = (B - (A * weightKilos) / hSquared);
        return femaleVolume;
    }

    /**
     * Method 4 - This method will calculate the current BAC for both Male and
     * Female
     *
     * @param weightPounds, is weight in pounds
     * @param VAD, which volume distribution to use
     * @param metaRate, which metabolic rate to use
     * @param drinksConsumed, is number of total drinks consumed
     * @param hoursDrinking, is number of hours that have elapsed
     * @return BAC is the current Blood Alcohol Content percentage
     */
    public static double BAC(int weightPounds, double VAD, double metaRate, int drinksConsumed, int hoursDrinking) {

        // Defines constants for each item
        final double GRAMS_PER_POUND = 453.592;
        final int GRAMS_PER_DRINK = 14;

        // Computes pounds into grams
        double weightGrams = weightPounds * GRAMS_PER_POUND;

        // Computes total of grams of alcohol consued
        int gramsAlcoholConsumed = drinksConsumed * GRAMS_PER_DRINK;

        // Computes initial BAC (needed for current BAC)
        double initBAC = ((gramsAlcoholConsumed / (weightGrams * VAD))
                * 100);

        // Computes current BAC = initial BAC  - (hours * metabolic rate )
        double currentBAC = (initBAC -(hoursDrinking * metaRate));

        // Returns current BAC
        return currentBAC;

    }

    /**
     * Method 5 - This method will display all results
     *
     * @param drinksConsumed, total number of drinks consumed
     * @param hoursDrinking, total number of hours that have elapsed
     * @param maleBAC, current male BAC
     * @param femaleBAC, current female BAC
     */
    public static void getResults(int drinksConsumed, int hoursDrinking, double maleBAC, double femaleBAC) {

        // Begins output of results
        System.out.println();
        System.out.println("After drinking " + drinksConsumed + " drinks, "
                + "in " + hoursDrinking + " hours:");
        System.out.printf("\tCurrent BAC for a male will be approximately %.3f\n",
                 maleBAC);
        System.out.printf("\tCurrent BAC for a female will be approximately %.3f\n",
                 femaleBAC);

    }
}

Attachments:

Answers

(5)
Status NEW Posted 08 Nov 2017 02:11 PM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)