Question

write java gui that Calculate BMI based on user input • Allows users to set their...

write java gui that

Calculate BMI based on user input

• Allows users to set their own goals


• Tracks calories, fats, cholesterol, sodium, and protein, based on user input (date
and amount consumed)


• Notifies users if they are reaching their limit


• Congratulates users if they reached their goal.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;
public class Categories {

public static void main(String[] args) {
BMICalc();
BMICalcBonus1();
BMICalcBonus1FeetInches();
}

public static String BMICategory(double BMI) {
if (BMI < 18.5) {
return "underweight";
}
if (BMI >= 18.5 && BMI <= 24.9) {
return "normal weight";
}
if (BMI >= 25.0 && BMI <= 29.9) {
return "overweight";
}
if (BMI >= 30.0) {
return "obese";
}
return null;
}

public static String BMIMoreCategories(double BMI) {
if (BMI < 15.0) {
return "very severely underweight";
}
if (BMI >= 15.0 && BMI <= 16.0) {
return "severely underweight";
}
if (BMI >= 16.1 && BMI <= 18.4) {
return "underweight";
}
if (BMI >= 18.5 && BMI <= 24.9) {
return "normal weight";
}
if (BMI >= 25.0 && BMI <= 29.9) {
return "overweight";
}
if (BMI >= 30.0 && BMI <= 34.9) {
return "moderately obese";
}
if (BMI >= 35.0 && BMI <= 39.9) {
return "severely obese";
}
if (BMI >= 40.0) {
return "very severely (or \"morbidly\") obese";
}
return null;
}

public static void BMICalc() {
Scanner keyboard = new Scanner(System.in);
double height, weight, BMI;
System.out.print("Your height in m: ");
height = keyboard.nextDouble();
System.out.print("Your weight in kg: ");
weight = keyboard.nextDouble();
BMI = weight / (height * height);
System.out.println();
System.out.println("Your BMI is " + BMI);
System.out.println("BMI Category: " + BMICategory(BMI));
System.out.println("BMI More Category: " + BMIMoreCategories(BMI));
}

public static void BMICalcBonus1() {
Scanner keyboard = new Scanner(System.in);
double height, weight, BMI;
System.out.print("Your height in inches: ");
height = keyboard.nextDouble();
System.out.print("Your weight in pounds: ");
weight = keyboard.nextDouble();
BMI = weight * (703 / (height * height));
System.out.println();
System.out.println("Your BMI is " + BMI);
System.out.println("BMI Category: " + BMICategory(BMI));
System.out.println("BMI More Category: " + BMIMoreCategories(BMI));
}

public static void BMICalcBonus1FeetInches() {
Scanner keyboard = new Scanner(System.in);
double height, heightFeet, heightInches, weight, BMI;
System.out.print("Your height (feet only): ");
heightFeet = keyboard.nextDouble();
System.out.print("Your height (inches): ");
heightInches = keyboard.nextDouble();
System.out.print("Your weight in pounds: ");
weight = keyboard.nextDouble();
height = heightFeet * 12 + heightInches;
BMI = weight * (703 / (height * height));
System.out.println();
System.out.println("Your BMI is " + BMI);
System.out.println("BMI Category: " + BMICategory(BMI));
System.out.println("BMI More Category: " + BMIMoreCategories(BMI));
}
}

Add a comment
Know the answer?
Add Answer to:
write java gui that Calculate BMI based on user input • Allows users to set their...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You will be designing and creating a Java GUI-based course application. Create a “Student” class. You...

    You will be designing and creating a Java GUI-based course application. Create a “Student” class. You need to have at least 3 instance variables (student characteristics like name,…), at least 2 constructors (1 should be a no-arg constructor), set and get methods. Create a “Course” class that consists of 2 instance variables: the course name and an array of Students (using your Student class). Design and create a JavaFX-based GUI interface that allows you to : INPUT information for Course...

  • the first question java code eclipse app the second question is java fx gui caculator please...

    the first question java code eclipse app the second question is java fx gui caculator please fast 1. Create project called "YourFirstName_QUID'. Eg. Aliomar_202002345 2. Create two package Q1 and Q2. 3. Add your name and studentID as comments on the top of each Java source file you submit. Question 1. Bookings APP [80 Points-six parts] Implement the following hotel booking system. Use the following class diagram to understand the structure of the system's classes, their attributes operations (or methods),...

  • I need to create a code based off of what the users first name and last...

    I need to create a code based off of what the users first name and last name are along with a random set of numbers no longer than 10 characters as the picture below demonstrate (Java language) Scenario: You have been appointed by the CS department to create a username generator to create CS email accounts automatically. The CS email will have the following format: Username@cs.utep.du. Your username must have a limit of 10 characters. Your program, will provide three...

  • write a detailed summary in an organized format. It must include 3-4 key points of the...

    write a detailed summary in an organized format. It must include 3-4 key points of the controversy. Break up your summary in 3-4 paragraphs. Must include specific reasons as to why a vegetarian diet can be better and or worse than the meat heavy diets? Explain briefly using examples how reading this controversy has helped you in making better dietary choices in future? CONTROVERSY 6 Table of Contents Vegetarian and Meat-Containing Diets: What Are the Benefits and Pitfalls? Notebook LO...

  • The administration of President Barack Obama has made Patient Protection and Affordable Care Act, often called...

    The administration of President Barack Obama has made Patient Protection and Affordable Care Act, often called “Obamacare”, its chief domestic accomplishment and the centerpiece of Obama’s legacy. Essential to Obama’s health care reform plan is Healthcare.gov, a health insurance exchange Web site that facilitates the sale of private health insurance plans to U.S. residents, assists people eligible to sign up for Medicaid, and has a separate marketplace for small businesses. The site allows users to compare prices on health insurance...

  • Below is the information: It is important to understand the different leadership styles employed by nursing...

    Below is the information: It is important to understand the different leadership styles employed by nursing leaders in healthcare organizations and to understand their significance on nursing practice and patient outcomes, for better or for worse. Objective: Read the articles from Nursing Standard (PDF) and Bradley University (PDF). In -250 words, formulate an opinion on the following: 1. Reflect on an occasion where you experienced ineffective leadership (doesn't have to be in the hospital). What behaviors did they display? What...

  • First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below...

    First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below Include each of the following in your answer (if applicable – explain in a paragraph) Research problem: what do you want to solve using Delphi? Sample: who will participate and why? (answer in 5 -10 sentences) Round one questionnaire: include 5 hypothetical questions you would like to ask Discuss: what are possible outcomes of the findings from your study? Hint: this is the conclusion....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT