Código de Java - Convertir entre Fahrenheit y Celsius

Versión 1

Publicado el 5 de Noviembre del 2012gráfica de visualizaciones de la versión: Versión 1
19.041 visualizaciones desde el 5 de Noviembre del 2012
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella


Forma parte de The::Beastieux
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//Codificado por sAfOrAs
import javax.swing.JOptionPane;
public class DSCTemperatura
{
    /*
    La relación entre grados Celsius (C) y grados Fahrenheit (F) es la siguiente: F - 32 = 1,8 * C
    */
    double FahrenheitCelsius(double grado)
    {
        double gCelsius=(grado-32)/1.8;
        return gCelsius;
    }
 
    double CelsiusFahrenheit(double grado)
    {
        double gFahrenheit=(grado*1.8)+32;
        return gFahrenheit;
    }
 
    public static void main(String[] args)
    {
        double grado=0,gCelsius=0,gFahrenheit=0;
        DSCTemperatura temp = new DSCTemperatura();
 
        int opcion=0;
        String cadena;
    do{
    cadena=JOptionPane.showInputDialog("\n [1] Convertir Fahrenheit - Celsius \n [2] Convertir Celsius - Fahrenheit");
    opcion=Integer.parseInt(cadena);
    }while(opcion<1 || opcion>2);
            cadena=JOptionPane.showInputDialog("Ingrese la temperatura: ");
            grado=Double.parseDouble(cadena);
 
    switch(opcion)
        {
            case 1: {
                gCelsius=temp.FahrenheitCelsius(grado);
                JOptionPane.showMessageDialog(null," TEMPERATURA: "+gCelsius + " Celsius");
                };break;
            case 2: {
                gFahrenheit=temp.CelsiusFahrenheit(grado);
                JOptionPane.showMessageDialog(null," TEMPERATURA: "+gFahrenheit +" Fahrenheit");
                };break;
        }
    }
}



Comentarios sobre la versión: Versión 1 (0)


No hay comentarios
 

Comentar la versión: Versión 1

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s2240