Write the code for the harrisbenedict program

Assignment Help JAVA Programming
Reference no: EM132430698

Write the code for the HarrisBenedict program to accept input for a person's weight, height, and age, and then display the basal metabolic rate for that person.

Afterwards, ask the user to choose from a selection of foods and then output the number they may eat to maintain their current body weight based on their BMR.

Note:

  • Use named constants to store the number of calories for each food item.
  • You are required to perform input validation for the sex user input. Force the user to enter m, M, f, or F.
  • You are required to perform input validation for the food selection input. Force the user to enter 1, 2, or 3.
  • You are not required to perform input validation for the weight, height, or age inputs.

Sample session:

Welcome to the basal metabolic rate calculator.

Are you male 'm' or female 'f': T

Invalid input. Please enter 'm' for male or 'f' for female.

Are you male 'm' or female 'f': m

How much do you weight (in pounds)?: 160

How tall are you (in inches)?: 70

What is your age?: 22

 

You entered:

Sex: m

Weight: 160 lbs

Height: 70 inches

Age: 22 years old

Your basal metabolic rate is 1798.28

 

What food would you like to eat?

1) Chocolate Bar (210 calories)

2) Pepperoni Pizza Slice (300 calories)

3) Baby Carrot (4 calories)

Selection: 4

 

Sorry, that's not a selection. Try another number.

Selection: 3

 

With your BMR, you can eat 449.57 baby carrots to maintain your body weight.

Thank you for using the basal metabolic rate calculator.

 

 

This is what I have so far:

 

import java.util.Scanner;

 

public class BMR

{

  public static void main(String[] args) 

  {

    int userChoice;

    int age = 0;

    double kgToPounds = 2.2046;

    double inchesToCms = 2.54;

    double heightInCms;

    double WeightInkg;

    double rate = 0;   

 

  Scanner in = new Scanner ( System.in );  

   

  System.out.print("Welcome to the basal metabolic calculator.");

System.out.println();

  System.out.print("Are you male 'm' or female 'f': ");

  String gender = in.next();

  System.out.print("What is your age? ");

  String ageString = in.next();

  age = Integer.parseInt(ageString);

  System.out.print("How tall are you (in inches)? ");

  String heightString = in.next();

  double height = Double.parseDouble(heightString);

  System.out.print("How much do you weigh (in pounds)? ");

  String weightString = in.next();

  double weight = Double.parseDouble(weightString);

   

     

  heightInCms = height * inchesToCms; // Do metric conversion

  WeightInkg = weight / kgToPounds;  // Do metric conversion

   

     

  System.out.println("Calculate your Basal Metabolism");

System.out.print("n");

   

if (gender.startsWith("M")) {

  System.out.println(" I am a male ");

rate = (66.5 + (13.75 * WeightInkg) + (5.003 * heightInCms) - (6.755 * age));

}

else {

rate = (655.1 + (9.563 * WeightInkg) + (1.850 * heightInCms) - (4.676 * age));

}

System.out.println("You entered: ");

System.out.println("Sex: " + gender);

System.out.println("Weight (kg): " + WeightInkg);

System.out.println("Height (cm): " + heightInCms);

System.out.println("Age: " + age);

System.out.println();

System.out.println("You basal metabolic rate is " + rate);

   

  }

}

Reference no: EM132430698

Questions Cloud

Storage format for digital evidence-linux-proprietary tool : You are responsible for protecting integrity of data you collect from hard drive. Compare and contrast the viable use of a Linux tool versus a proprietary tool.
What are the user benefits of sharepoint : Question 1: What are the user benefits of Sharepoint (a microsoft app)? Question 2: What are the organization benefits of Sharepoint?
How the framework was used to inform the research study : Describe how the framework was used to inform the research study. How much did the researchers write about it in the journal article?
Differences between two approaches : Research and discuss the differences between these two approaches. In what situations would it be appropriate to use an array to hold data
Write the code for the harrisbenedict program : Write the code for the HarrisBenedict program to accept input for a person's weight, height, and age, and then display the basal metabolic rate for that person.
Describe the type of risk management plan you selected : Conduct research on approaches to risk management processes, policies, and concerns in your current or anticipated professional arena to find an example.
The strategic sourcing plan : The strategic sourcing plan is a plan for how you will do business going forward. The sourcing plan can address how to supply resources to staff,
Instantiate a new array named myfavoritemovies : Instantiate a new array named myFavoriteMovies with 6 type String components. Call method inputArray to fill the array with your favorite movies
Conduct an assessment of the health care environment : Conduct an assessment of the health care environment where you work (i.e. health department, long-term care facility, specialty clinic, inpatient hospital, etc)

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd