Question

Write a Java program that performs these operations Prompt the user to enter a low height in feet (an integer) Prompt the user to enter a high height in feet (an integer) Prompt the user to enter a low weight in pounds (an integer) Prompt the user to enter a high weight in pounds (an integer) Print a table of Body Mass Index (BMI) for the heights and weights entered, ranging from the low height to the high height (inclusive), at increments of 3 inches, and for each weight, from the low weight to the high weight (inclusive), in increments of pp pounds Each row of the table lists the height in feet and inches (two integers separated by a space), followed by 4 spaces, followed by the weight (an integer), followed by 9 spaces then the BMI to four decimal places (a float), followed by 9 spaces, then test the user according to the following BMI table BMI Interpretation below 16 16-18 18-24 24-29 29-35 above 35 serious underweight underweight normal weight overweight seriously overweight gravely overweight

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

in this question, pp pounds is not mentioned so I have taken the increment of 5 pounds. You can set to your desired value in the inner for loop

Java code

--------------------------------------------------------------------------------------------------------------------------------

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bmi_table;

import java.util.Scanner;

import java.text.DecimalFormat;
/**
*
* @author satsahib
*/
public class BMI_table {

//find BMI value
static double BMI(int w,int h)
{
double bmi;
bmi=703*((double)w/(h*h));
//System.out.println(bmi);
return bmi;
  
}
//find descrption of BMI value
static String BMI_I(double bmi)
{
String str="";
if(bmi<16)
str="serious underweight";
else if(bmi<18)
str="underweight";
else if(bmi<24)
str="normal weight";
else if(bmi<29)
str="overweight";
else if(bmi<35)
str="seriously overweight";
else
str="gravely overweight";
  
return str;
}
public static void main(String[] args) {
// TODO code application logic here
int lowHeight,highHeight,lowWeight,highWeight;
Scanner sc=new Scanner(System.in);
//input form user
System.out.print("Enter low height in feet: ");
lowHeight=sc.nextInt();
System.out.print("Enter high height in feet: ");
highHeight=sc.nextInt();
  
System.out.print("Enter low weight in pounds: ");
lowWeight=sc.nextInt();
System.out.print("Enter high weight in pounds: ");
highWeight=sc.nextInt();

//to format output to 4 decimal places
DecimalFormat df = new DecimalFormat("###.####");
int i,j;
double bmivalue;
String s;

System.out.println("feet inches weight BMI BMI_descrption");
for(i=lowHeight*12;i<=highHeight*12;i+=3)
{
for(j=lowWeight;j<=highWeight;j+=5)
{
bmivalue=BMI(j,i);
s=BMI_I(bmivalue);

System.out.println(i/12+" "+i+" "+" "+j+" "+df.format(bmivalue)+" "+s);
}
}
  

}
  
}

-----------------------------------------------------------------------------------------------------------------------------------

Output

。BMI-table-NetBeans IDE 8.2 File Edit View Navigate Source Refactor Run Debug Profie Teem Iools Window Help Search (Ct1+) def

Add a comment
Know the answer?
Add Answer to:
Write a Java program that performs these operations Prompt the user to enter a low height...
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
  • Y F G Prompt and Store. 5. Prompt the user with "Enter your weight in pounds:...

    Y F G Prompt and Store. 5. Prompt the user with "Enter your weight in pounds: "message and store in the weight variable. 6. Initialize an int variable named heightIn Inches to feet OſHeight times 12 plus Inches OfHeight. 7. Initialize a double variable named BMI to weight * 703.0 heightIrinches El VB 8. Initialize a double variable named ratio to height In Inches? 703.0 9. Initialize a double variable named lower Normal to 18.5 times ratio. 10. Initialize a...

  • /////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates...

    /////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates the user's body-mass-index (BMI) // 3. and then prints an appropriate message based on the user's BMI /////////////////////////////////////////////////////////////////////////////////// #include <iostream> using namespace std; void printWelcome(); // ask the weight (in pounds) and height (in inches) of the user and store the values in formal // parameters weight and height, respectively void getWeightAndHeight(float& weight, float& height); // calculate and return the BMI (Body-Mass-Index) based on...

  • Check the given program for errors and write the correct program : height = float(input("Enter height...

    Check the given program for errors and write the correct program : height = float(input("Enter height in meters: ")) weight = float(input("Enter weight in kg: ")); bmi == weight/(height**2) print("Your BMI is:”,bmi”) if ( bmi< 16) print("severely underweight") elif ( bmi>= 16 and bmi< 18.5): print("underweight") elif ( bmi>= 18.5 and bmi< 25): print("Healthy") elif ( bmi>= 25 and bmi< 30): print("overweight") elif ( bmi>=30): print("severely overweight") elseif: print(“Not in Range) Rewrite the entire program correctly and calculate the bmi...

  • Write a single C++ program that performs the following conversion (The modulus divide will help you...

    Write a single C++ program that performs the following conversion (The modulus divide will help you get the remainder as shown in class) 39 / 12 = 3 and 39 % 12 = 3, so 3 feet 3 inch(es) Height conversion 1 meter = 39 inches 12 inches = 1 foot Ask/Prompt the user to enter in the height in meters, convert and output the result in feet and inches Example 1 meters as input should produce 3 feet (foot)...

  • Complete the Python program below that performs the following operations. First prompt the user to input...

    Complete the Python program below that performs the following operations. First prompt the user to input two integers, n and m. If n<m, then print the odd positive integers that are less than m (in order, on a single line, separated by spaces). If man, then print the even positive integers that are less than n (in order, on a single line, separated by spaces). If neem, then print nothing. For instance, if the user enters 5 followed by 10,...

  • EASY JAVA PROGRAM 10. Write a program called CalculateBMI. Ask the user for their height in...

    EASY JAVA PROGRAM 10. Write a program called CalculateBMI. Ask the user for their height in inches and their weight in pounds. Then, compute and report their BMI. You will need to look up the formula for BMI online and perform any necessary unit conversions. Print the result with two digits after the decimal place

  • IT Java code In Lab 8, we are going to re-write Lab 3 and add code...

    IT Java code In Lab 8, we are going to re-write Lab 3 and add code to validate user input. The Body Mass Index (BMI) is a calculation used to categorize whether a person’s weight is at a healthy level for a given height. The formula is as follows:                 bmi = kilograms / (meters2)                 where kilograms = person’s weight in kilograms, meters = person’s height in meters BMI is then categorized as follows: Classification BMI Range Underweight Less...

  • Using C++ cs 102 REVIEW LAB Selection a) Minimum/Maximum: Nrite a program that asks the user...

    Using C++ cs 102 REVIEW LAB Selection a) Minimum/Maximum: Nrite a program that asks the user to enter two numbers. The progzan should use the conditional operator to determine which number is the smaller and which is the larger. Display your output in the format below: The smaller number is: (smallerNumber) The larger number is: ClargerNumber] b) Areas of Rectangles: The area of a rectangle is calculated by maltiplying its length tines its width. Write a program that asks the...

  • Write a program (code) that performs the following: Height and Weight for Male and Female: Robinson...

    Write a program (code) that performs the following: Height and Weight for Male and Female: Robinson formula to calculate the body relative to the height in inches is as follow: Ideal weight in kilogram = 52 + 1.9 * (height - 60) for male Ideal weight in kilogram = 49 + 1.7 * (height - 60) for female Write a program that prompts the user to enter the gender ('M' or 'm' for male and 'F' or feet and inches,...

  • Write a basic C++ program that will calculate a subject’s basal metabolic rate and estimate how...

    Write a basic C++ program that will calculate a subject’s basal metabolic rate and estimate how many days it will take to lose a specific number of pounds. The program will perform the following tasks: Declare variables and Named constants. Display “Welcome to <your name>’s Weight Loss Calculator” Prompt the user to enter the subject’s current weight. Prompt the user to enter the subject’s height in feet plus inches. Prompt the user to enter the subject’s age. Prompt the user...

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
ADVERTISEMENT