namespace practica_11_examen
{
class Program
{
static void Main(string[] args)
{
int [,] ventas = new int[10, 30];
string[] vendedores = new string[10];
double[] totales = new double[10];
double mayor=0;
int posmayor=0;
int venta = 0;
double suma = 0;
int v = 0;
int i = 0;
Random random = new Random();
for (v = 0; v <=9 ; v = v + 1)
{
suma = 0;
Console.Write("\nNum.= "+v+" Introduce el nombre del vendedor= ");
vendedores[v] = (Console.ReadLine());
for (i = 0; i <=29; i = i + 1)
{
venta =(random.Next(1, 9));
ventas[v,i] = venta;
Console.Write(venta + "\t");
suma = suma + ventas[v,i];
}
totales[v] = suma;
}
for (v = 0; v <= 9; v = v + 1)
{
if (totales[v] > mayor)
{
mayor = totales[v];
posmayor = v;
}
}
Console.WriteLine("Nombre del vendedor\tVenta total");
for (v = 0; v <= 9; v = v + 1)
{
Console.WriteLine(vendedores[v] + "\t\t" + totales[v]);
}
Console.WriteLine("Monto de venta= " + mayor);
Console.WriteLine("Vendedor con el mayor numero de ventas: " + vendedores[posmayor]);
Console.ReadKey();
}
}
}
namespace problema_2_visual
{
public partial class Form1 : Form
{
string[] vendedores;
int[,] ventas;
double[] total;
double suma;
int i, c;
double mayor;
int posmayor;
Random v = new Random();
public Form1()
{
InitializeComponent();
vendedores= new string[10];
ventas = new int[10, 30];
total = new double[10];
i = c = 0;
suma = 0;
mayor = 0;
posmayor = 0;
}
private void button1_Click(object sender, EventArgs e)
{
if (i < 10)
{
vendedores[i] = textBox1.Text;
textBox1.Clear();
textBox1.Focus();
i++;
}
if (i == 10)
{
button1.Enabled = false;
textBox1.Enabled = false;
}
}
private void button2_Click(object sender, EventArgs e)
{
for (i = 0; i < 10; i++)
{
suma = 0;
for (c = 0; c < 30; c++)
{
ventas[i, c] = v.Next(0, 100);
suma = suma + ventas[i, c];
}
total[i] = suma;
}
for (i = 0; i < 10; i++)
{
if (total[i] > mayor)
{
mayor = total[i];
posmayor = i;
}
}
}
private void button3_Click(object sender, EventArgs e)
{
string salida;
for (i = 0; i < 10; i++)
{
salida = vendedores[i];
for (c = 0; c < 30; c++)
{
salida = salida + "\t" + ventas[i, c];
}
listBox1.Items.Add(salida);
}
listBox1.Items.Add("Vendedor con mayor numero de ventas: " + vendedores[posmayor]);
listBox1.Items.Add("Monto de venta= " + mayor);
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Enabled = true;
i = c = 0;
listBox1.Items.Clear();
string[] vendedores=new string[10] ;
int[,] ventas=new int [10,30];
double[] total=new double[10];
textBox1.Focus();
textBox1.Clear();
button1.Enabled = true;
}
private void button5_Click(object sender, EventArgs e)
{
Close();
}
}
}
viernes, 21 de mayo de 2010
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario