Elabore um programa que calcule o indice de massa corporal (IMC) atraves do peso e da altura fornecida pelo usuario. Dependendo do valor obtido o programa devera mostrar uma mensagem de alerta conforme tabela abaixo.//Autor: Thiago Campos//Data: 28.01.2014/** * * @author Thiago */public class jFVisor extends javax.swing.JFrame {//declaracao das variaveis float peso; float altura; float imc; /** * Creates newform jFVisor */ public jFVisor() { initComponents(); } /** * This method iscalled from within the constructor to initialize the form. * WARNING: Do NOTmodify this code. The content of this method is always * regenerated bythe Form Editor. */ @SuppressWarnings("unchecked") // <editor-folddefaultstate="collapsed" desc="Generated Code"> private voidinitComponents() { jPanel1 = newjavax.swing.JPanel(); jTAltura = newjavax.swing.JTextField(); jTPeso = newjavax.swing.JTextField(); jTImc = newjavax.swing.JTextField(); jLabel1 = newjavax.swing.JLabel(); jLabel2 = newjavax.swing.JLabel(); jLabel3 = newjavax.swing.JLabel(); jBCalcular =new javax.swing.JButton(); jBLimpar = newjavax.swing.JButton(); jPanel2 = newjavax.swing.JPanel(); jLResultado =new javax.swing.JLabel(); jLabel4 = newjavax.swing.JLabel(); jLabel5 = newjavax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null,"IMC", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,javax.swing.border.TitledBorder.DEFAULT_POSITION, newjava.awt.Font("Aharoni", 0, 18))); // NOI18N jLabel1.setText("Altura"); jLabel2.setText("Peso"); jLabel3.setText("IMC"); jBCalcular.setText("Calcular"); jBCalcular.addActionListener(new java.awt.event.ActionListener() { publicvoid actionPerformed(java.awt.event.ActionEvent evt) { jBCalcularActionPerformed(evt); } }); jBLimpar.setText("Limpar"); jBLimpar.addActionListener(new java.awt.event.ActionListener() { publicvoid actionPerformed(java.awt.event.ActionEvent evt) { jBLimparActionPerformed(evt); } }); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultado")); javax.swing.GroupLayout jPanel2Layout = newjavax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLResultado, javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jLResultado, javax.swing.GroupLayout.PREFERRED_SIZE, 48,javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 8, Short.MAX_VALUE)) ); javax.swing.GroupLayout jPanel1Layout = newjavax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,false) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2)) .addGap(52, 52,52) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTAltura) .addComponent(jTPeso))) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jBCalcular) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jBLimpar)))) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel3) .addGap(18, 18, 18) .addComponent(jTImc)))) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTAltura, javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addGap(18,18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTPeso, javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jBCalcular) .addComponent(jBLimpar)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jTImc,javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(35, 35, 35)) ); jLabel4.setText("Autor:Thiago Campos"); jLabel5.setText("Data: 28/01/2014"); javax.swing.GroupLayout layout = newjavax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4) .addComponent(jLabel5)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel4) .addGap(11, 11, 11) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 255,javax.swing.GroupLayout.PREFERRED_SIZE)) ); pack(); }//</editor-fold> private voidjBCalcularActionPerformed(java.awt.event.ActionEvent evt) { // TODO addyour handling code here: altura =Float.valueOf(jTAltura.getText()); //pega os valores dos campos peso =Float.valueOf(jTPeso.getText()); imc =peso/(altura*altura); //calculo jTImc.setText(String.valueOf(imc)); //faz aparecero resultado em imc jLResultado.setText(verificaImc(imc)); //setando oresultado no campo Resultado } private voidjBLimparActionPerformed(java.awt.event.ActionEvent evt) { // TODO addyour handling code here: jTAltura.setText(""); jTPeso.setText(""); jTImc.setText(""); jLResultado.setText(""); } public StringverificaImc (float imc){ Stringresultado = ""; if(imc <=18.5){ resultado= "Voce esta abaixo do peso"; }else if(imc> 18.5 && imc <= 24.9){ resultado= "Peso Normal"; }else if(imc> 25.0 && imc <= 29.9){ resultado= "Sobrepeso"; }else if(imc> 30.0 && imc <= 34.9){ resultado= "Obsidade - Grau I"; }else if(imc> 35.0 && imc <= 39.9){ resultado= "Obsidade - Grau II"; }else if(imc> 40.0){ resultado= "Obsidade - Grau III"; } returnresultado; } /** * @param args thecommand line arguments */ public static voidmain(String args[]) { /* Set theNimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Lookand feel setting code (optional) "> /* If Nimbus(introduced in Java SE 6) is not available, stay with the default look andfeel. * For detailssee http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for(javax.swing.UIManager.LookAndFeelInfo info :javax.swing.UIManager.getInstalledLookAndFeels()) { if("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch(ClassNotFoundException ex) { java.util.logging.Logger.getLogger(jFVisor.class.getName()).log(java.util.logging.Level.SEVERE,null, ex); } catch(InstantiationException ex) { java.util.logging.Logger.getLogger(jFVisor.class.getName()).log(java.util.logging.Level.SEVERE,null, ex); } catch(IllegalAccessException ex)