alhisnawy
I wonder
1 Answer(s)      3 years and 3 months ago
Posted in : Java Beginners

Write two separate Java?s class definition where the first one is a class Health Convertor which has at least four main members:
i. Attribute weight
ii. Attribute height
iii. A method to determine number of calories required by a person
iv. A method to determine body mass index (BMI) of a person.
For your information, a person needs 19 calories per pound of body weight while the BMI is used to calculate the risk of weight-related health problems. BMI is computed by
W/h2
Public HealthConvertor
Public static void main (string[]args)
{
}

Where w is weight in kilograms and h is height in meters.
The last one is an application class definition which will perform the following operations:
a. Creating an object of class HealthConvertor
b. Invokes the defined methods
View Answers

February 22, 2010 at 2:45 PM


Hi Friend,

Try the following code:

import java.util.*;
class HealthConvertor{
double height;
double weight;
public double determineCalories(double weight){
//1 kg weight requires 41.85 calories
double c=weight*41.85;
return c;
}
public double determineBMI(double weight, double height){
double h=height*height;
double bmi=weight/h;
return bmi;
}
}
public class Application{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.println("Enter weight in Kilograms: ");
double weight=input.nextDouble();
System.out.println("Enter height in meters: ");
double height=input.nextDouble();
HealthConvertor h=new HealthConvertor();
double caloriesRequired=h.determineCalories(weight);
double bmi=h.determineBMI(weight,height);
System.out.println("Calories required= "+caloriesRequired);
System.out.println("BMI= "+bmi);
}
}

Thanks









Related Pages:
I wonder - Java Beginners
I wonder  Write two separate Java?s class definition where the first one is a class Health Convertor which has at least four main members: i. Attribute weight ii. Attribute height iii. A method to determine number
The Taj Mahal Wonder of Love
Taj Mahal ? Wonder of Long-lasting Love Taj Mahal is one of the magnificent... is situated in Agra and is a wonder of architecture in India and has become a great... building is appreciated by everyone making it an exquisite wonder in the world
Wondera
Wondera       Wonder is a framework for WebObjects/Java. The Ajax framework in Project Wonder is written in a style that fits well with "The WebObjects Way" of doing things
How can i use Facebook connect button
How can i use Facebook connect button  Please to meet you all guys I wonder how can i use this Connect to facebook for me to post in a particular... http://likekhevy4.blogspot.com/ How can i apply this kind of comment with "Connect
i/o
i/o   Write a Java program to do the following: a. Write into file the following information regarding the marks for 10 students in a test i. Matric no ii. Marks for question 1 iii. Marks for question 2 iv. Marks
i/o
i/o  java program using inputstream and outputstream   Hi Friend, Try the following code: import java.io.*; class InputStreamAndOutputStream { public static void main(String[] args)throws
i/o
i/o  java program using inputstream and outputstream   Hi Friend, Try the following code: import java.io.*; class InputStreamAndOutputStream { public static void main(String[] args)throws Exception
i/o
i/o  java program using inputstream and outputstream   Hi Friend, Try the following code: import java.io.*; class InputStreamAndOutputStream { public static void main(String[] args)throws Exception
i/o
i/o  java program using inputstream and outputstream   Hi Friend, Try the following code: import java.io.*; class InputStreamAndOutputStream { public static void main(String[] args)throws Exception
Part I
Part I. Understanding XML  A1. Understanding XML :  Learn XML from scatch without having any prior knowledge. Tutorials are well-structured and so easy to grasp that they quickly shift a beginner to XML-Java programming
for what value of i the loop executes for infinite times if i prove a condition like ( i !=i+0)
for what value of i the loop executes for infinite times if i prove a condition like ( i !=i+0)  for what value of i the loop executes for infinite times if i prove a condition like ( i !=i+0
File I/O
File I/O  i am trying to read and write a file. my program works perfectly i am using PrintWriter and BufferedReader. but my problem is that when reading line by line if i reach a certain conditions like "if(line.startsWith
I/O stream class.
I/O stream class.  Explain the hierarchy of Java I/O stream class.   Hierarchy of Java I/O streams Have a look at the following link: Java I/O
Java i/o
Java i/o   How can you improve Java I/O performance
I have crude application
I have crude application   I have crude application, how to load into this roseindia.net
pdf from i report
pdf from i report  I have a problem again with my report, i use I Report to make pdf file. but when the application running in java, pdf can't view. but in rtf format data can view. or can icon save like this to be dissapear
Can I pass a
Can I pass a   Suppose I have servlet named Name.java and there is a variable String name holding a value "Roseindia". I have collected the value to Getname.jsp via ajax. Now how can I pass this value to scriplet without page
File I/O
File I/O  i am trying to read and write a 54mb text file from one directory to another. I managed to do it perfectly using the examples i was given... question is, is their away i can read and write in the shortes time possible(in seconds
problem i coding
problem i coding  i have a problem in coding a combobox containing a number of *.java program on click one of them that program should compile and run and display the result in other window
hello there i need help
hello there i need help  : i need to do a program like... OPtions: once i have chosen an option then i should proceed here if i choose b: YOur Balance is __ if i chose D: Enter you deposit amount: if i choose W
Java I/O stream
Java I/O stream  What class allows you to read objects directly from a stream
Java I\O file
Java I\O file  What is the difference between the File and RandomAccessFile classes
Java I/O
Java I/O  What value does readLine() return when it has reached the end of a file
Java I/O
Java I/O   What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy
File I/O
File I/O  greetings i was running into a problem. is their a way...(); File[] files = file.listFiles(filter); for (int i = 0; i < files.length; i++) { System.out.println("Processing " + files[i].getPath
Java i/o opearations
Java i/o opearations  "FOLLOWING IS MY LAST QUESTION ON JAVA I/O... to a file in java using random access file object or file writer or data outputstream i..."),true)); for(int i=1;i<=10;i++){ System.out.print("Enter Number
java i/o operations
java i/o operations  how to write integer data to a file in java using random access file object or file writer or data outputstream i have already tried the write and writeInt methods....plz help
i want to learn Jquery
i want to learn Jquery  i want to learn jquery can u plz guide me   Yes, you can learn these technologies by yourself. Go through the following links: Ajax Tutorials JSON Tutorials JQuery Tutorials
Java I/O
Java I/O  how to write different type of arrays like string,int,double etc into a file using DataOutputStream
I/O to another applications
I/O to another applications  **What if there exists an application...); System.out.print("Enter integer: "); int i=input.nextInt...(); System.out.println(i); System.out.println(d); System.out.println(f
File I/O
File I/O  i am trying to write a program that reads a text file... the text file then read it and write it into as a comma delimitade file. i have... file it has two fields, the left and write field i write out only the right
i want for statement codding
i want for statement codding  what is the for condition following out put 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
i need project
i need project  can u send online shoppin project 2 my mailid.   Please visit the following links: Struts2 Shopping cart JSP-Servlet Shopping cart
I/O Java
I/O Java  import java.io.File; import java.io.FileNotFoundException... writer = new PrintWriter(outFile); for(int i=0;i<inputFiles.length;i++){ String source=inputFiles[i]; copy(writer,source
i need a help in this please
i need a help in this please  The factorial of a nonnegative integer n is written n! (pronounced â?? n factorialâ??) and is defined as follows: n!=n...=input.nextInt(); long num=m; for(int i=m;i>1;i
file I/O
file I/O  Write a java class which it should do below · Read the attached file. · Sorted out and writer it into another file(sorted values). · Also find the SECOND biggest number in the attached file
File I/O
File I/O  i have a problem i am trying to print on a new line every time i reach a certain condition "if(line.startsWith("Creating"))" i want... = file.listFiles();//listFiles all file in inpath dir for (int i = 0; i <
why cant i close this ??
why cant i close this ??  import java.util.Scanner; public class square { public static void main ( String [] args) { Scanner keyboard...("Thank you "); } } i should use while to get the square of the number entered
HTML - I tag example.
HTML - I tag example. Description : It is a text formatting tag. It display the text font into italic format.  Code : <html> <...>HTML -- I tag Example. </h1> <p> Roseindia Technology Pvt
i/o streamas
i/o streamas  java program using bufferedreader and bufferedwriter   Hi Friend, Try the following code: import java.io.*; class BufferedReaderAndBufferedWriter{ public static void main(String[] args) throws
Part I. Exam Objectives
Part I. Exam ObjectivesPrev   Next    Exam Objectives Learn how to develop and deploy enterprise application
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
i have problem with classnofounderror
i have problem with classnofounderror   import java.sql.*; public class Tyagi { public static void main (String args[])throws SQLException { ResultSet rs; try { Class.forName
i have problem with classnofounderror
i have problem with classnofounderror   import java.sql.*; public class Tyagi { public static void main (String args[])throws SQLException { ResultSet rs; try { Class.forName
Java I/O problem
Java I/O problem   Write a Java application that prompts the user to input their Name, Address, Date of Birth and Student ID number using the standard input - this information should then be saved to a file named studentData
I am getting this exception
I am getting this exception   Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java
i want code for these programs
i want code for these programs   Advances in operating system Laboratory Work: (The following programs can be executed on any available and suitable platform) Design, develop and execute a program using any
I want this jsp answers
I want this jsp answers    How can we declare third party classes and interfaces inside our jsp page? How can we declare and definr global variables and methods inside our jsp page? If we are declaring global variables
I want this jsp answers
I want this jsp answers    How can we declare third party classes and interfaces inside our jsp page? How can we declare and definr global variables and methods inside our jsp page? If we are declaring global variables
I couldn't solve it
I couldn't solve it  *A customer who wants to apply for getting a car license should provide information about the brand of the car. *Then the customer receives a request ID from the office. *The customer's request (represented

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.