Ejemplo switch case Calculando Grados Fahrenheit Celsius y Kelvin as3
En este ejemplo de as3 utilizaremos Las Formulas de conversión de incrementos
de grados Fahrenheit Celsius y Kelvin para calcular el valor de temperatura Introducido utilizando el switch.
Formulas:
Fahrenheit a Celsius C =(F-32)*5/9
Fahrenheit a Kelvin K = (F-32)*5/9 +273
Celsius a Fahrenheit F =C*9/5+32
Celsius a Kelvin K=C+273
Kelvin a Fahrenheit F= (k-273)9/5+32
Kelvin a Celsius C=K-273
primero el Diseño:
Ocuparemos 3 label, 1 combobox, 1 TextInput y 1 button
aqui el codigo:
Ejemplo switch case Calculando Grados as3
de grados Fahrenheit Celsius y Kelvin para calcular el valor de temperatura Introducido utilizando el switch.
Formulas:
Fahrenheit a Celsius C =(F-32)*5/9
Fahrenheit a Kelvin K = (F-32)*5/9 +273
Celsius a Fahrenheit F =C*9/5+32
Celsius a Kelvin K=C+273
Kelvin a Fahrenheit F= (k-273)9/5+32
Kelvin a Celsius C=K-273
primero el Diseño:
Ocuparemos 3 label, 1 combobox, 1 TextInput y 1 button
aqui el codigo:
btn1.addEventListener(MouseEvent.CLICK, accion);
function accion(event:MouseEvent):void
{//lol
switch (combo1.text){
case "Fahrenheit a Celsius":
//C =(F-32)*5/9
lb2.text=String((Number(txt.text)-32)*5/9 )+" C";
break;
case "Fahrenheit a Kelvin":
//K = (F-32)*5/9 +273
lb2.text=String((Number(txt.text)-32)*5/9 +273)+" K";
break;
case "Celsius a Fahrenheit":
// F =C*9/5+32
lb2.text=String((Number(txt.text)*9/5)+32 )+" F";
break;
case "Celsius a Kelvin":
// K=C+273
lb2.text=String(Number(txt.text)+273 )+" K";
break;
case "Kelvin a Fahrenheit":
// F= (k-273)9/5+32
lb2.text=String((Number(txt.text)-273)*9/5 +32 )+" F";
break;
case "Kelvin a Celsius":
// C=K-273
lb2.text=String(Number(txt.text)-273 )+" C";
break;
}
};//fin funcion
Descargar Ejemplo:Ejemplo switch case Calculando Grados as3

Comentarios
Publicar un comentario