send
Grupo de Telegram
play_arrow
Este sitio utiliza cookies propias y de terceros. Si continúa navegando consideramos que acepta el uso de cookies. OK Más Información.

Conversor de temperatura

  • 1 Respuestas
  • 1941 Vistas

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado rush

  • *
  • Underc0der
  • Mensajes: 378
  • Actividad:
    0%
  • Reputación 7
    • Ver Perfil
  • Skype: iruxh1773
« en: Julio 29, 2015, 04:05:35 pm »
Bueno, me agarro un momento de oscio y me puse a hacer un conversor de temperatura asi que aqui les dejo el jar y el source, creo que se puede mejorar pero solo fue porque no tenia nada que hacer.


Código: Java
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package temperatura;
  7.  
  8. import javax.swing.ButtonGroup;
  9.  
  10. /**
  11.  *
  12.  * @author rush
  13.  */
  14. public class Ventana extends javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login {
  15.  
  16.     /**
  17.      * Creates new form Ventana
  18.      */
  19.     public Ventana() {
  20.         initComponents();
  21.     }
  22.  
  23.     /**
  24.      * This method is called from within the constructor to initialize the form.
  25.      * WARNING: Do NOT modify this code. The content of this method is always
  26.      * regenerated by the Form Editor.
  27.      */
  28.     @SuppressWarnings("unchecked")
  29.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  30.     private void initComponents() {
  31.  
  32.         grupo1 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  33.         grupo2 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  34.         jRadioButton1 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  35.         jButton1 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  36.         jRadioButton2 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  37.         jRadioButton3 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  38.         jLabel1 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  39.         jLabel2 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  40.         jTextField1 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  41.         jTextField2 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  42.         jRadioButton4 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  43.         jRadioButton5 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  44.         jRadioButton6 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  45.         jLabel3 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  46.         jLabel4 = new javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  47.  
  48.         setDefaultCloseOperation(javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.EXIT_ON_CLOSE);
  49.  
  50.         grupo1.add(jRadioButton1);
  51.         jRadioButton1.setSelected(true);
  52.         jRadioButton1.setText("Celsius");
  53.  
  54.         jButton1.setText("Convertir");
  55.         jButton1.addActionListener(new java.awt.event.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login() {
  56.             public void actionPerformed(java.awt.event.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login evt) {
  57.                 jButton1ActionPerformed(evt);
  58.             }
  59.         });
  60.  
  61.         grupo1.add(jRadioButton2);
  62.         jRadioButton2.setText("Fahrenheit");
  63.  
  64.         grupo1.add(jRadioButton3);
  65.         jRadioButton3.setText("Kelvin");
  66.  
  67.         jLabel1.setText("Temperatura");
  68.  
  69.         jLabel2.setText("Conversion");
  70.  
  71.         jTextField2.setEditable(false);
  72.  
  73.         grupo2.add(jRadioButton4);
  74.         jRadioButton4.setText("Celsius");
  75.  
  76.         grupo2.add(jRadioButton5);
  77.         jRadioButton5.setSelected(true);
  78.         jRadioButton5.setText("Fahrenheit");
  79.  
  80.         grupo2.add(jRadioButton6);
  81.         jRadioButton6.setText("Kelvin");
  82.  
  83.         jLabel3.setFont(new java.awt.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login("Tahoma", 1, 11)); // NOI18N
  84.         jLabel3.setText("De");
  85.  
  86.         jLabel4.setFont(new java.awt.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login("Tahoma", 1, 11)); // NOI18N
  87.         jLabel4.setText("A");
  88.  
  89.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  90.         getContentPane().setLayout(layout);
  91.         layout.setHorizontalGroup(
  92.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  93.             .addGroup(layout.createSequentialGroup()
  94.                 .addContainerGap()
  95.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  96.                     .addGroup(layout.createSequentialGroup()
  97.                         .addComponent(jLabel1)
  98.                         .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.MAX_VALUE))
  99.                     .addGroup(layout.createSequentialGroup()
  100.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  101.                             .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  102.                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  103.                                     .addComponent(jLabel2)
  104.                                     .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
  105.                                 .addComponent(jTextField2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
  106.                             .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING))
  107.                         .addGap(18, 18, 18)
  108.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  109.                             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  110.                                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  111.                                     .addComponent(jRadioButton1)
  112.                                     .addComponent(jRadioButton3)
  113.                                     .addComponent(jRadioButton2))
  114.                                 .addGap(18, 18, 18))
  115.                             .addGroup(layout.createSequentialGroup()
  116.                                 .addComponent(jLabel3)
  117.                                 .addGap(80, 80, 80)))
  118.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  119.                             .addComponent(jLabel4)
  120.                             .addComponent(jRadioButton6)
  121.                             .addComponent(jRadioButton5)
  122.                             .addComponent(jRadioButton4))
  123.                         .addGap(50, 50, 50))))
  124.         );
  125.         layout.setVerticalGroup(
  126.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  127.             .addGroup(layout.createSequentialGroup()
  128.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  129.                     .addGroup(layout.createSequentialGroup()
  130.                         .addContainerGap()
  131.                         .addComponent(jLabel1)
  132.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  133.                         .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  134.                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  135.                         .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.MAX_VALUE)
  136.                         .addComponent(jLabel3)
  137.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  138.                         .addComponent(jRadioButton1)))
  139.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  140.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  141.                     .addGroup(layout.createSequentialGroup()
  142.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  143.                             .addComponent(jLabel2)
  144.                             .addComponent(jRadioButton2))
  145.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  146.                         .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  147.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  148.                         .addComponent(jButton1))
  149.                     .addGroup(layout.createSequentialGroup()
  150.                         .addGap(23, 23, 23)
  151.                         .addComponent(jRadioButton3)))
  152.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.MAX_VALUE))
  153.             .addGroup(layout.createSequentialGroup()
  154.                 .addGap(17, 17, 17)
  155.                 .addComponent(jLabel4)
  156.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  157.                 .addComponent(jRadioButton4)
  158.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  159.                 .addComponent(jRadioButton5)
  160.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  161.                 .addComponent(jRadioButton6)
  162.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.MAX_VALUE))
  163.         );
  164.  
  165.         pack();
  166.     }// </editor-fold>                        
  167.  
  168.     private void jButton1ActionPerformed(java.awt.event.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login evt) {                                        
  169.         Conv conv = new Conv();
  170.         float r;
  171.         //Celicus a celcius
  172.         if(jRadioButton1.isSelected() && jRadioButton4.isSelected()){
  173.             jTextField2.setText(jTextField1.getText());
  174.         }
  175.         //Celicus a Fahrenheit
  176.         else if(jRadioButton1.isSelected() && jRadioButton5.isSelected()){
  177.             r = conv.CaF(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.parseFloat(jTextField1.getText()));
  178.             jTextField2.setText(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.toString(r));
  179.         }
  180.         //Celcius a Kelvin
  181.         else if(jRadioButton1.isSelected() && jRadioButton6.isSelected()){
  182.             r = conv.CaK(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.parseFloat(jTextField1.getText()));
  183.             jTextField2.setText(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.toString(r));
  184.         }
  185.         //Fahrenheit a Celcius
  186.         else if(jRadioButton2.isSelected() && jRadioButton4.isSelected()){
  187.             r = conv.FaC(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.parseFloat(jTextField1.getText()));
  188.             jTextField2.setText(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.toString(r));
  189.         }
  190.         //Fahrenheit a Fahrenheit
  191.         else if(jRadioButton2.isSelected() && jRadioButton5.isSelected()){
  192.             jTextField2.setText(jTextField1.getText());
  193.         }
  194.         //Fahrenheit a Kelvin
  195.         else if(jRadioButton2.isSelected() && jRadioButton6.isSelected()){
  196.             r = conv.FaK(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.parseFloat(jTextField1.getText()));
  197.             jTextField2.setText(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.toString(r));
  198.         }
  199.         //Kelvin a Celicus
  200.         else if(jRadioButton3.isSelected() && jRadioButton4.isSelected()){
  201.             r = conv.KaC(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.parseFloat(jTextField1.getText()));
  202.             jTextField2.setText(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.toString(r));
  203.         }
  204.         //Kelvin a Fahrenheit
  205.         else if(jRadioButton3.isSelected() && jRadioButton5.isSelected()){
  206.             r = conv.KaF(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.parseFloat(jTextField1.getText()));
  207.             jTextField2.setText(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.toString(r));
  208.         }
  209.         //Kelvin a Kelvin
  210.         else if(jRadioButton3.isSelected() && jRadioButton6.isSelected()){
  211.             jTextField2.setText(jTextField1.getText());
  212.         }
  213.     }                                        
  214.  
  215.     /**
  216.      * @param args the command line arguments
  217.      */
  218.     public static void main(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login args[]) {
  219.         /* Set the Nimbus look and feel */
  220.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  221.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  222.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  223.          */
  224.         try {
  225.             for (javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login info : javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.getInstalledLookAndFeels()) {
  226.                 if ("Nimbus".equals(info.getName())) {
  227.                     javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.setLookAndFeel(info.getClassName());
  228.                     break;
  229.                 }
  230.             }
  231.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login ex) {
  232.             java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  233.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login ex) {
  234.             java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  235.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login ex) {
  236.             java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  237.         } catch (javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login ex) {
  238.             java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  239.         }
  240.         //</editor-fold>
  241.  
  242.         /* Create and display the form */
  243.         java.awt.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.invokeLater(new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login() {
  244.             public void run() {
  245.                 new Ventana().setVisible(true);
  246.             }
  247.         });
  248.     }
  249.     // Variables declaration - do not modify                    
  250.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login grupo1;
  251.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login grupo2;
  252.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jButton1;
  253.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jLabel1;
  254.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jLabel2;
  255.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jLabel3;
  256.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jLabel4;
  257.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jRadioButton1;
  258.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jRadioButton2;
  259.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jRadioButton3;
  260.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jRadioButton4;
  261.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jRadioButton5;
  262.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jRadioButton6;
  263.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jTextField1;
  264.     private javax.swing.You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login jTextField2;
  265.     // End of variables declaration                  
  266. }
  267.  

Código: Java
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package temperatura;
  7.  
  8. /**
  9.  *
  10.  * @author rush
  11.  */
  12. public class Conv {
  13.     float FaC(float temp){
  14.         float c=0;
  15.         c = (5*(temp - 32))/9;
  16.         return c;
  17.     }
  18.    
  19.     float CaF(float temp){
  20.         float f=0;
  21.         f = ((9*temp)/5)+32;
  22.         return f;
  23.     }
  24.    
  25.     float CaK(float temp){
  26.         float k=0;
  27.         k = temp + 273.15f;
  28.         return k;
  29.     }
  30.    
  31.     float FaK(float temp){
  32.         float k=0;
  33.         k = ((5*(temp - 32))/9)+273.15f;
  34.         return k;
  35.     }
  36.    
  37.     float KaC(float temp){
  38.         float k=0;
  39.         k = temp - 273.15f;
  40.         return k;
  41.     }
  42.    
  43.     float KaF(float temp){
  44.         float k=0;
  45.         k = ((9*(temp - 273.15f))/5)+32;
  46.         return k;
  47.     }
  48. }
  49.  

You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
« Última modificación: Julio 29, 2015, 04:18:40 pm por WhiZ »
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login


Desconectado Gus Garsaky

  • *
  • Underc0der
  • Mensajes: 93
  • Actividad:
    0%
  • Reputación -1
    • Ver Perfil
  • Skype: gus.garsaky
« Respuesta #1 en: Julio 29, 2015, 05:10:14 pm »
Buen aporte, rush.

 

¿Te gustó el post? COMPARTILO!



Conversor ASCI a Hex para inyecciones by andresg888

Iniciado por ProcessKill

Respuestas: 0
Vistas: 1569
Último mensaje Febrero 24, 2010, 04:13:18 pm
por ProcessKill
Conversor de números decimales a binario

Iniciado por darkbouser

Respuestas: 3
Vistas: 1763
Último mensaje Febrero 09, 2015, 03:31:16 pm
por Hu3c0