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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


alhisnawy
I wonder
1 Answer(s)      4 years and 9 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

Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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
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 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
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
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
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
I have crude application
I have crude application   I have crude application, how to load into this roseindia.net
Java i/o
Java i/o   How can you improve Java I/O performance
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
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
I need an example of sessionfactory
I need an example of sessionfactory  Hi, I need an example of session factory in hibernate. If you can provide me one with, that would be great...Thanks
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 this: Automatic Teller Machine [B] Balance [D] Deposit [W] Withdrawal [Q] Quit select you OPtions: once i have chosen an option then i should proceed here if i choose b
Java I/O
Java I/O   What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy
Java I/O
Java I/O  What value does readLine() return when it has reached the end of a file
Java I\O file
Java I\O file  What is the difference between the File and RandomAccessFile classes
Java I/O stream
Java I/O stream  What class allows you to read objects directly from a stream
i want to update values
i want to update values  in my form i have 2 submit buttons one... database and it need to insert automatically in to disabled text boxs and once i press the edit button all text boxs need to enable so that i can edit my details
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
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 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
Java I/O
Java I/O  how to write different type of arrays like string,int,double etc into a file using DataOutputStream
 

 

 

DMCA.com