QuestionAsk Questions?

could someone help me with this

heightInInches( ) takes 2 integer parameters, feet and inches which represents someone?s height and returns that height in inches

weightInPounds( ) takes 2 integer parameters, stone and pounds which represents someone?s weight and returns that weight in pounds

calculateBMI( ) takes 2 integer parameters, height in inches and weight in pounds and returns the BMI using the formula: weight * 703 / height2

The main method in BMIChecker should read the data and pass it as parameters to the appropriate methods.

View Answers

November 7, 2011 at 5:57 PM

import java.util.*; public class BMIChecker { static int heightInInches( int f,int i){ int in=f*12; int inches=i+in; return inches; } static int weightInPounds(int stone, int p){ int po=stone*14; int pounds=p+po; return pounds; } static int calculateBMI(int height,int weight ){ int w=weight*703; int h=height*height; int bmi = w/h; return bmi; } public static void main(String[] args){ Scanner input=new Scanner(System.in); System.out.print("Enter height in feet: "); int feet=input.nextInt(); System.out.print("Enter height in inch: "); int inch=input.nextInt(); System.out.print("Enter weight in stone: "); int stone=input.nextInt(); System.out.print("Enter height in pound: "); int pound=input.nextInt(); int height=heightInInches(feet,inch); int weight=weightInPounds(stone,pound); int bmi=calculateBMI(height,weight); System.out.println("BMI is: "+bmi); } }

Related Tutorials/Questions & Answers:

Advertisements