NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package swing_grupi;

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

////////////////////////////////////////////////////////////// class BMI
class BMI extends JFrame {
//=============================================== static method main
public static void main(String[] args) {
BMI window = new BMI();
window.setVisible(true);
}


private JTextField _mField = new JTextField(4); // height
private JTextField _kgField = new JTextField(4); // weight
private JTextField _bmiField = new JTextField(4); // BMI


public BMI() {

JButton bmiButton = new JButton("Compute BMI");
bmiButton.addActionListener(new BMIListener());

//... Set layout and add components.
JPanel content = new JPanel();
content.setLayout(new FlowLayout());
content.add(new JLabel("Weight in kilograms"));
content.add(_kgField);
content.add(new JLabel("Height in meters"));
content.add(_mField);
content.add(bmiButton);
content.add(new JLabel("Your BMI is"));
content.add(_bmiField);


setContentPane(content);
setTitle("Body Mass Index");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack(); // Do layout.
setLocationRelativeTo(null); // Center window.
}


private class BMIListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
double kilograms = Double.parseDouble(_kgField.getText());
double meters = Double.parseDouble(_mField.getText());
int bmi = (int)computeBMI(kilograms, meters);
_bmiField.setText("" + bmi);//afishon rezultatin
}
}


public static double computeBMI(double weight, double height) {
return weight / (height * height);
}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.