Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

Fresher Job


 

Search Host

Monthly Fee($)
Disk Space (MB)
Register With us for Newsletter!
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

Tutorials

Java Server Pages

JAXB

Java Beans

JDBC

MySQL

Java Servlets

Struts

Bioinformatics

Java Code Examples

Interview Questions

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Web Promotion

Web Submission

Submit Sites

Manual Submission?

Web Promotion Guide

Hosting Companies

Web Hosting Guide

Web Hosting

Linux

Beginner Guide to Linux Server

Frameworks

Persistence Framework

Web Frameworks

Free EAI Tools

Web Servers

Aspect Oriented Programming

Free Proxy Servers

Softwares

Adware & Spyware Remover

Open Source Softwares

Java programming 1
Expert:Kaito
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 programming
...n i jus learn until simple method not further method yet..haha
Answers
Hi friend,


1. Ask the user for their height. Convert it to a double.
2. Ask the user for their weight. Convert it to a double.
3. Use the formula BMI = weight / (height * height) to calculate the BMI.
4. Display the BMI number along with a message about their weight. These are the National Institute of Health official categories, but it might be more interesting to create your own messages.
* Underweight for BMI < 18.5
* Normal for BMI from 18.5 up to 25
* Overweight for BMI from 25 to 30
* Obese for BMI over 30
------------------------------------

Here is the code.

import javax.swing.JFrame;

class BMI {
public static void main(String[] args) {
JFrame frame = new JFrame("Body Mass Index");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(new BMIPanelDemo());
frame.setSize(300,200);
frame.setVisible(true);
}
}


------------------------------------------------------

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

class BMIPanelDemo extends JPanel {
private JTextField m_mField = new JTextField(4); // height
private JTextField m_kgField = new JTextField(4); // weight
private JTextField m_bmiField = new JTextField(4); // BMI

BMIPanelDemo() {
//Create button and add an action listener
JButton bmiButton = new JButton("Compute BMI");
bmiButton.addActionListener(new BMIListener());

//Set layout and add components.
this.setLayout(new FlowLayout());
this.add(new JLabel("Weight in kilograms"));
this.add(m_kgField);
this.add(new JLabel("Height in meters"));
this.add(m_mField);
this.add(bmiButton);
this.add(new JLabel("Your BMI is"));
this.add(m_bmiField);
}

private class BMIListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
double kilograms = Double.parseDouble(m_kgField.getText());
double meters = Double.parseDouble(m_mField.getText());
int bmi = (int)computeBMI(kilograms, meters);
m_bmiField.setText("" + bmi);
}
}

public static double computeBMI(double weight, double height) {
return weight / (height*height);
}
}
----------------------------------

Thanks.

More Questions
Post Answers
 
Ask Question Facing Programming Problem?
Useful Links
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.