package tfprogUNIPILOTO;
import [Link];
/**
* @author oscarivan
*
*/
public class ConversionTemperatura {
/**
*
*/
//****************************************************
//****************************************************
//****************************************************
//Atributos de la clase Conversion Temperatura
private double celsius;
private double farenheit;
private double kelvin;
//****************************************************
//****************************************************
//****************************************************
//Mtodos de lgica de la clase
//
public double readValorConv (String message)
{
double valorConver = 0;
valorConver =
[Link]([Link](null,message));
return (valorConver);
}
public int readEscala (String message)
{
int escala;
escala =
[Link]([Link](null,message));
return (escala);
}
public double convCelsius (double valorConver, int escala)
{
if (escala==1)
{
celsius=valorConver;
}
if (escala == 2)
{
celsius = (valorConver - 32 * 5)/9;
}
if (escala == 3)
{
celsius = valorConver - 273.15;
}
return (celsius);
}
public double convFarenheit (double valorConver, int escala)
{
if (escala==1)
{
farenheit = (valorConver * 9/5) + 32;
}
if (escala == 2)
{
farenheit = valorConver;
}
if (escala==3)
{
farenheit = (valorConver*9/5)- 459.67;
}
return (farenheit);
}
public double convKelvin(double valorConver, int escala)
{
if (escala==1)
{
kelvin = valorConver + 273.15;
}
if (escala == 2)
{
kelvin = (valorConver + 459.67)*5/9;
}
if (escala==3)
{
kelvin = valorConver;
}
return (kelvin);
}
public void printResult (double valorConver, char type, double
celsius,double farenheit, double kelvin )
{
if (type == 'c')
{
[Link](null," Los "
+valorConver+
" CELSIUS al convertirlos son: "+farenheit+
" FARENHEIT y "+kelvin+" KELVIN ");
}
if (type == 'f' )
{
[Link](null," Los "
+valorConver+
" FARENHEIT al convertirlos son:
"+celsius+
" CELSIUS y "+kelvin+" KELVIN ");
}
if (type == 'k' )
{
[Link](null," Los "
+valorConver+
" KELVIN al convertirlos son: "+celsius+
" CELSIUS y "+farenheit+" FARENHEIT");
}
}
public double getCentigrados() {
return celsius;
}
public void setCentigrados(double celsius) {
[Link] = celsius;
}
public double getFarenheit() {
return farenheit;
}
public void setFarenheit(double farenheit) {
[Link] = farenheit;
}
public double getKelvin() {
return kelvin;
}
public void setKelvin(double kelvin) {
[Link] = kelvin;
}
}
PRINCIPAL
package tfprogUNIPILOTO;
import [Link];
/**
* @author oscarivan
*
*/
public class ConversionTemperaturaTest {
/**
*
*/
public ConversionTemperaturaTest() {
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ConversionTemperatura convTemp = new ConversionTemperatura();
int escala = 0;
double valorConver= 0.0;
double celsius = 0.0;
double farenheit = 0.0;
double kelvin = 0.0;
[Link](null,"BIENVENIDO AL PROGRAMA DE
CONVERSION DE TEMPERATURA");
[Link](null,"Las escalas que maneja el
programa son " +
" CELSIUS= 1 , FARENHEIT = 2 , KELVIN = 3 ");
escala = [Link](" Que Escala de temperatura
quiere convertir: ");
valorConver = [Link](" Ingrese los grados a
convetir ");
celsius=[Link](valorConver, escala);
farenheit=[Link](valorConver, escala);
kelvin=[Link](valorConver, escala);
farenheit,
farenheit,
farenheit,
numeros 1,
}
if (escala==1)
{
[Link](valorConver,'c', celsius,
kelvin);
}
if (escala==2)
{
[Link](valorConver,'f', celsius,
kelvin);
}
if (escala==3)
{
[Link](valorConver,'k', celsius,
kelvin);
}
else if (escala!=1&&escala!=2&&escala!=3)
{
[Link](null," Escoga solo los
2 o 3 para las escalas de temperatura");
}