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

  Design - uml diagrams and overall design

CE00882-4 -  Design - UML diagrams and overall design and implement Java Code - a well-documented code should be submitted.

  Method called wordlengths that accepts a scanner

Write a method called wordLengths that accepts a Scanner representing an input file as its argument. Your method should read from the given file.

  Demonstrates conditions under which the compareto() method

Write an application that demonstrates conditions under which the compareTo() method retrun a positive number, a negative number, and a zero when used to compare two Strings, Save the file as CompareStringValues.java. Lab Assignment

  Calculate the maximum flow of a directed weighted graph

Comp 251 Assignment. We will implement the Ford-Fulkerson algorithm to calculate the Maximum Flow of a directed weighted graph. Here, you will use the files WGraph.java and FordFulker-son.java, which are available on the course website. Your role ..

  Design an object hierarchy

Design an object hierarchy and design your own UML class diagram to reflect the classes and relationship required by your program.

  Compute the sum of the first n positive odd integers

Write JAVA program that will compute the sum of the first n positive odd integers.  For example, if n is 5, you should compute 1 + 3 + 5 + 7 + 9.

  Write a program to play a rock-paper-scissors game in java

Write a program to play a rock-paper-scissors game in Java? Two users take turns entering R, P, or S.

  Create a corba idl program as a distributed application

The Project will consist of building a CORBA distributed application using Java IDL. You are to build a CORBA IDL program as a distributed application.

  Physical address and a virtual address

What is the difference between a physical address and a virtual address?

  Describe different professional levels in this discipline

What is Anesthesiology and critical care medicine describe the specific discipline, what is their focus (i.e., emergency medicine, education and prevention, psychiatric treatment etc.) Describe the different professional levels in this discipline

  Write a program to track hourly employee departure

A company hires you to write a program to track hourly employee arrival and departure times from work. In essence, you are tasked to make an online time clock.

  Implement the request processing thread

Java TCP Networking, Multi-threading and Object Serialization Programming - A Java application to implement the compute-server

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