I wonder

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 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 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
ModuleNotFoundError: No module named 'GSAS-II-WONDER-linux'
ModuleNotFoundError: No module named 'GSAS-II-WONDER-linux'  Hi...: No module named 'GSAS-II-WONDER-linux' How to remove the ModuleNotFoundError: No module named 'GSAS-II-WONDER-linux' error? Thanks   Hi
Advertisements
ModuleNotFoundError: No module named 'GSAS-II-WONDER-osx'
ModuleNotFoundError: No module named 'GSAS-II-WONDER-osx'  Hi, My... named 'GSAS-II-WONDER-osx' How to remove the ModuleNotFoundError: No module named 'GSAS-II-WONDER-osx' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'GSAS-II-WONDER-win'
ModuleNotFoundError: No module named 'GSAS-II-WONDER-win'  Hi, My... named 'GSAS-II-WONDER-win' How to remove the ModuleNotFoundError: No module named 'GSAS-II-WONDER-win' error? Thanks   Hi, In your
The Taj Mahal Wonder of Love
Taj Mahal Wonder of Long-lasting Love Taj Mahal is one of the magnificent... and is a wonder of architecture in India and has become a great place for tourists... is appreciated by everyone making it an exquisite wonder in the world representing
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
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
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
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
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
ModuleNotFoundError: No module named 'i'
ModuleNotFoundError: No module named 'i'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'i' How to remove the ModuleNotFoundError: No module named 'i' error
ModuleNotFoundError: No module named 'i'
ModuleNotFoundError: No module named 'i'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'i' How to remove the ModuleNotFoundError: No module named 'i' error
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
I want to learn maven
I want to learn maven  Hi, I have to work on the maven based projects in my company. So, I want to learn it in 5-6 days. How to start learning Maven? Can I learn Maven in 5-6 days. Thanks
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 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
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 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
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 want to learn maven
I want to learn maven  Hi, I have to work on the maven based projects in my company. So, I want to learn it in 5-6 days. How to start learning Maven? Can I learn Maven in 5-6 days. Thanks   Hi, First of all I would
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 <
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
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
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

Ads