Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. public class JFVisor extends javax.swing.JFrame {
  2. float peso;
  3. float altura;
  4. float imc;
  5.  
  6.  
  7. public JFVisor() {
  8. initComponents();
  9. }
  10. private void jTPesoActionPerformed(java.awt.event.ActionEvent evt) {
  11.  
  12. }
  13.  
  14. private void jBCalcularActionPerformed(java.awt.event.ActionEvent evt) {
  15.  
  16. altura = Float.valueOf(jTAltura.getText());
  17. peso = Float.valueOf(jTPeso.getText());
  18. imc = peso/(altura*altura);
  19. jTImc.setText(String.valueOf(imc).substring(0, 5));
  20. jLResultado.setText(verificaImc(imc));
  21. }
  22.  
  23. private void jBLimparActionPerformed(java.awt.event.ActionEvent evt) {
  24. // TODO add your handling code here:
  25. jTAltura.setText("");
  26. jTPeso.setText("");
  27. jTImc.setText("");
  28. jLResultado.setText("");
  29. }
  30.  
  31. private void jBCalcularKeyPressed(java.awt.event.KeyEvent evt) {
  32.  
  33. altura = Float.valueOf(jTAltura.getText());
  34. peso = Float.valueOf(jTPeso.getText());
  35. imc = peso/(altura*altura);
  36. jTImc.setText(String.valueOf(imc).substring(0, 5));
  37. jLResultado.setText(verificaImc(imc));
  38. }
  39.  
  40. private void jBLimparKeyPressed(java.awt.event.KeyEvent evt) {
  41.  
  42. jTAltura.setText("");
  43. jTPeso.setText("");
  44. jTImc.setText("");
  45. jLResultado.setText("");
  46. }
  47.  
  48. private void jTAlturaActionPerformed(java.awt.event.ActionEvent evt) {
  49.  
  50. }
  51. public String verificaImc(float imc){
  52. String resultado = null;
  53. if(imc <=18.5)
  54. resultado = "Abaixo do peso, procure um médico";
  55. else if(imc >18.5 && imc <= 24.9)
  56. resultado = "Peso Normal, Parabéns";
  57. else if(imc >=25.0 && imc <= 29.9)
  58. resultado = "Sobre peso, atenção";
  59. else if(imc >=30.0 && imc <= 34.9)
  60. resultado = "Obesidade grau I, faça uma dieta";
  61. else if(imc >=35.0 && imc <= 39.9)
  62. resultado = "Obesidade grau II, procure um médico";
  63. else if(imc >40.0)
  64. resultado = "Obesidade grau III, VÁ ao médico";
  65. return resultado;
  66. }
  67.  
  68. public static void main(String args[]) {
  69. }
  70. // Variables declaration - do not modify
  71. private javax.swing.JButton jBCalcular;
  72. private javax.swing.JButton jBLimpar;
  73. private javax.swing.JLabel jLAltura;
  74. private javax.swing.JLabel jLImc;
  75. private javax.swing.JLabel jLPeso;
  76. private javax.swing.JLabel jLResultado;
  77. private javax.swing.JPanel jPanel1;
  78. private javax.swing.JPanel jPanel2;
  79. private javax.swing.JTextField jTAltura;
  80. private javax.swing.JTextField jTImc;
  81. private javax.swing.JTextField jTPeso;
  82. // End of variables declaration
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement