lunes, 28 de septiembre de 2009

PRACTICA 3-2 CONSOLA Y WINDOWS


PRACTICA CONSOLA


PRACTICA 3-2 CONSOLA

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace practica3_2_consola
{
class Program
{
static void Main(string[] args)
{
double radio, altura, volumen, area;
Console.WriteLine("introduce el radio de un cilindro");
altura = float.Parse(Console.ReadLine());
Console.WriteLine("introduce la altura de un cilindro");
radio = float.Parse(Console.ReadLine());
volumen = 3.1416 * radio * radio * altura;
area = 2 * (3.1416 * radio * radio + 3.1416 * radio * altura);
Console.WriteLine("el volumen del cilindro es{0} ", volumen);
Console.WriteLine("el area del cilindro es{0} ", area);
Console.ReadKey();
}
}
}




WINDOWS

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Practica_3._2_Visual
{
public partial class Form1 : Form
{
double r, a, v, area;
public Form1()
{
r = a = v = area = 0.0;
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
}

private void button1_Click(object sender, EventArgs e)
{
a = double.Parse(textBox2.Text);
r = double.Parse(textBox1.Text);
v = 3.1416 * r * r * a;
area = 2 * 3.1416 * r * r * a;
textBox3.Text = v.ToString();
textBox4.Text = area.ToString();
}

private void button3_Click(object sender, EventArgs e)
{
Close();
}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}

No hay comentarios:

Publicar un comentario