l
PRACTICA 3-1 CONSOLA Y WINDOWS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace practica3_1_consola
{
class Program
{
static void Main(string[] args)
{
double p, area, a, b, c;
Console.WriteLine("introduce las tre longitudes de un triangulo");
a = float.Parse(Console.ReadLine());
b = float.Parse(Console.ReadLine());
c = float.Parse(Console.ReadLine());
p = (a + b + c) / 2.0;
area = Math.Sqrt(p*(p - a)*(p - b)*(p - c));
Console.WriteLine("el area del triangulo 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._1_Visual
{
public partial class Form1 : Form
{
float a, b, c, p;
double area;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
a = float.Parse(textBox1.Text);
b = float.Parse(textBox2.Text);
c = float.Parse(textBox3.Text);
p = (a + b + c) / 2.0f;
area = Math.Sqrt(p * (p - a) * (p - b) * (p - c));
textBox4.Text = area.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
No hay comentarios:
Publicar un comentario