
namespace practica6_problema3V
{
public partial class Form1 : Form
{
F F1;
C F2;
K F3;
R F4;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
F1 = new F();
F1.Show();
}
private void button2_Click(object sender, EventArgs e)
{
F2 = new C();
F2.Show();
}
private void button3_Click(object sender, EventArgs e)
{
F3 = new K();
F3.Show();
}
private void button4_Click(object sender, EventArgs e)
{
F4 = new R();
F4.Show();
}
}
}
namespace practica6_problema3V
{
public partial class F : Form
{
double Fah, Cel, Kel, Ran;
public F()
{
InitializeComponent();
Fah = 0.0;
Cel = 0.0;
Kel = 0.0;
Ran = 0.0;
}
private void F_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Fah = double.Parse(textBox1.Text);
Cel = (5.0 / 9.0) * (Fah - 32.00);
Kel = Cel + 273.00;
Ran = Fah + 460;
listBox1.Items.Add("Celcius: " + Cel);
listBox1.Items.Add("Kelvin: " + Kel);
listBox1.Items.Add("Rankine: " + Ran);
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
listBox1.Items.Clear();
textBox1.Focus();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}
namespace practica6_problema3V
{
public partial class C : Form
{
double Fah, Cel, Kel, Ran;
public C()
{
InitializeComponent();
Fah = 0.0;
Cel = 0.0;
Kel = 0.0;
Ran = 0.0;
}
private void C_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Cel = double.Parse(textBox1.Text);
Fah = (9.0 / 5.0) * (Cel + 32);
Kel = Cel + 273;
Ran = Fah + 460;
listBox1.Items.Add("Fahrenheit: " + Fah);
listBox1.Items.Add("Kelvin: " + Kel);
listBox1.Items.Add("Rankine: " + Ran);
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
listBox1.Items.Clear();
textBox1.Focus();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}
namespace practica6_problema3V
{
public partial class K : Form
{
double Fah,Cel,Kel,Ran;
public K()
{
InitializeComponent();
Fah = 0.0;
Cel = 0.0;
Kel = 0.0;
Ran = 0.0;
}
private void button1_Click(object sender, EventArgs e)
{
Kel = double.Parse(textBox1.Text);
Cel = Kel - 273;
Fah = (9.0 / 5.0) * (Cel + 32.0);
Ran = Fah + 460;
listBox1.Items.Add("Fahrenheit: " + Fah);
listBox1.Items.Add("Celsius: " + Cel);
listBox1.Items.Add("Rankine: " + Ran);
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
listBox1.Items.Clear();
textBox1.Focus();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}
namespace practica6_problema3V
{
public partial class R : Form
{
double Fah, Cel, Kel, Ran;
public R()
{
InitializeComponent();
Fah = 0.0;
Cel = 0.0;
Kel = 0.0;
Ran = 0.0;
}
private void R_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Ran = double.Parse(textBox1.Text);
Fah = Ran - 460;
Cel = (5.0 / 9.0) * (Fah - 32.0);
Kel = Cel + 273;
listBox1.Items.Add("Fahrenheit: " + Fah);
listBox1.Items.Add("Celsius: " + Cel);
listBox1.Items.Add("Kelvin: " + Kel);
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
listBox1.Items.Clear();
listBox1.Focus();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}


namespace Practica6problema3
{
class Program
{
static void Main(string[] args)
{
double Celsius, Kelvin, Fahrenheit, Rankine;
char continuar;
do
{
Console.Clear();
Celsius = 0.0;
Kelvin = 0.0;
Fahrenheit = 0.0;
Rankine = 0.0;
Console.WriteLine("Que tipo de grados desea convertir");
Console.WriteLine(" a) Fahrenheit:");
Console.WriteLine(" b) Celsius:");
Console.WriteLine(" c) Kelvin:");
Console.WriteLine(" d) Rankine:");
string opcion = (Console.ReadLine());
switch (opcion)
{
case "a": Console.WriteLine("Introduce la cantidad de grados Fahrenheit:");
Fahrenheit = double.Parse(Console.ReadLine());
Celsius = (5.0 / 9.0) * (Fahrenheit - 32.00);
Kelvin = (Celsius + 273);
Rankine = (Fahrenheit + 460);
Console.WriteLine(" Las conversiones de grados Celsius son={0}", Celsius);
Console.WriteLine(" Las conversiones de grados Kelvin son={0}", Kelvin);
Console.WriteLine(" Las conversiones de grados Rankine son={0}", Rankine);
break;
case "b": Console.WriteLine("Introduce la cantidad de grados Celsius:");
Celsius = double.Parse(Console.ReadLine());
Fahrenheit = (9.0 / 5.0) * (Celsius + 32.00);
Kelvin = (Celsius + 273);
Rankine = (Fahrenheit + 460);
Console.WriteLine(" Las conversiones de grados Fahrenheit son={0}", Fahrenheit);
Console.WriteLine(" Las conversiones de grados Kelvin son={0}", Kelvin);
Console.WriteLine(" Las conversiones de grados Rankine son={0}", Rankine);
break;
case "c": Console.WriteLine("Introduce la cantidad de grados Kelvin:");
Kelvin = double.Parse(Console.ReadLine());
Celsius = (Kelvin - 273);
Fahrenheit = (9.0 / 5.0) * (Celsius + 32.00);
Rankine = (Fahrenheit + 460);
Console.WriteLine(" Las conversiones de grados Celsius son={0}", Celsius);
Console.WriteLine(" Las conversiones de grados Fahrenheit son={0}", Fahrenheit);
Console.WriteLine(" Las conversiones de grados Rankine son={0}", Rankine);
break;
case "d": Console.WriteLine("Introduce la cantidad de grados Rankine:");
Rankine = double.Parse(Console.ReadLine());
Fahrenheit = (Rankine - 460);
Celsius = (5.0 / 9.0) * (Fahrenheit - 32.00);
Kelvin = (Celsius + 273);
Console.WriteLine(" Las conversiones de grados Fahrenheit son={0}", Fahrenheit);
Console.WriteLine(" Las conversiones de grados Celsius son={0}", Celsius);
Console.WriteLine(" Las conversiones de grados Kelvin son={0}", Kelvin);
break;
default:
Console.WriteLine("ERROR");
break;
}
Console.Write("Desea calcular otra conversion s Si / n No : ");
continuar = char.Parse(Console.ReadLine());
}
while (continuar == 's');
Console.ReadKey();
}
}
}
No hay comentarios:
Publicar un comentario