Share on Google+Share on Google+

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

Ads

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
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
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
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads