Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


David Ferguson
Java BMI code
1 Answer(s)      2 years and 10 months ago
Posted in : Java Beginners


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.


Advertisement
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:
Java BMI code
Java BMI code  could someone help me with this heightInInches( ) takes 2 integer parameters, feet and inches which represents someone?s height... in pounds and returns the BMI using the formula: weight * 703 / height2 The main
BMI by using JSP Languange
BMI by using JSP Languange  Using JSP language, create a system that calculates Body Mass Index (BMI) of users who entered their weight and height. Then, system will display all the records. Can you provide me the coding
Advertisements
BMI by using JSP Languange
BMI by using JSP Languange  Using JSP language, create a system that calculates Body Mass Index (BMI) of users who entered their weight and height. Then, system will display all the records. Can you provide me the coding
BMI Calculator, BMI Calculator iPhone, BMI Calculator iPhone
BMI Calculator for iPhone Free iBMI Calculator Roseindia Technologies Pvt. Ltd. has offered a free utility tool – BODY MASS INDEX (BMI... calculators for calculating the BMI rate of the body, which accurate
JAVA code For
JAVA code For   JAVA code For "Traffic signals Identification for vehicles
Java programming - Java Beginners
Java programming  write a method that computes the Body Mass Index (BMI) given the weight (kg) and height (metres) and displays a message as detailed... will then calculate the BMI and display the results using a JOptionPane
java code
java code  write a java code to convert hindi to english using arrays
JAVA CODE
JAVA CODE  JAVA SOURCE CODE TO BLOCK A PARTICULAR WEB SITES(SOCIAL WEB SITE
java code
java code  what is the code to turn off my pc through java program
Java programming 1 - Java Beginners
is the code. import javax.swing.JFrame; class BMI { public static void...Java programming 1  thx sir for reply me..but sir can u pls simplify it? cos the answer is not up to my requirement regarding the BMI index
java code
java code  hi any one please tell me the java code to access any link i mean which method of which class is used to open any link in java program
java code
java code  sir how to merge the cells in excel using java code please help me and also how to make the text placed in the cell to be center
java code
java code  sir how to merge the cells in excel using java code please help me and also how to make the text placed in the cell to be center
java code
java code  write a java code for finding a string in partiular position in a delimited text file and replace the word with the values given by user and write the file in new location
java code
java code  need java code for chart or graph which compare the performance of aprior algorithm and coherent rule algorithm.plz any one help me out
java code
java code  I need the java code that would output the following: HARDWARE ITEMS CODE DESCRIPTION UNIT PRICE K16 Wood screws,brass,20mm $7.75 D24 Wood glue,clear,1 liter $5.50 M93
Java code
Java code   Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes
java code
java code  develop a banking system in java
java code
java code  HOW TO PRINT 1 TO 100 WITHOUT USING CONDITIONAL,ANY LOOP AND ARRAY IN JAVA AND C.URGENT SIR PLZ  Hi, You can use following code: class MyClass { public static void main(String[] args) { int
java code
java code  how to extract html tags using java
java code
java code  int g() { System.out.println("Inside method g"); int h() { System.out.println("Inside method h"); } } Find the error in the following... cannot define a method inside another method. Anyways, we have modified your code
Java code
Java code  Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any... the following code: import java.util.*; import java.text.*; class NumberProgram
java code
java code  what is meaning bufferedreader
java code
java code  what is meaning bufferedreader
Java code
Java code  An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus...; Hi Friend, Try the following code: import java.util.*; import
Java code
Java code   Create a calculator class which will have methods add, multiply, divide & subtract   Hi Friend, Try the following code: class Calculation{ public int add(int a,int b){ return a+b
java code
java code  i want HSVcolor descriptor for color image in java coding
java code
java code  hi, Can any one tell me " How to read the data which is present om an image in java
Java Code
Java Code  Write a java program, which creates multiple threads. Each thread performs add/delete/update operations on an ArrayList simultaneously
java code
java code  I am beginer in java my question is how can i fill data from mysql database to jcombobox using netbeans
Java code
Java code  Create a class called Student which has the following methods: i. Average: which would accept marks of 3 examinations & return... & returns the name.   Hi Friend, Try the following code: import
Advertisements
 

 

 

DMCA.com