
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
int[] temp;
int i, suma, p;
public Form1()
{
InitializeComponent();
temp = new int[8];
i = suma = p = 0;
}
private void button1_Click(object sender, EventArgs e)
{
if(i<8)
{
temp[i]=int.Parse(textBox1.Text);
suma=suma+temp[i];
listBox1.Items.Add(temp[i]);
textBox1.Clear();
textBox1.Focus();
i++;
}
else
{
textBox1.Clear();
textBox1.Enabled=false;
button1.Enabled=false;
}
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Add("");
p=suma/8;
listBox1.Items.Add("promedio="+p.ToString());
}
}
}

No hay comentarios:
Publicar un comentario