
CODIGO EN CONSOLA
private void button1_Click(object sender, EventArgs e)
{
double cantidad ,codigo, precio,total,descuento,pago;
Console.WriteLine("Introduce cantidad de articulos");
cantidad=double.Parse( Console.ReadLine());
Console.WriteLine("Introduce codigo del articulo");
codigo = double.Parse(Console.ReadLine());
Console.WriteLine("Introduce el precio del articulo");
precio = double.Parse(Console.ReadLine());
if (cantidad >100)
{
Console.Write("Descuento del 40%");
total=cantidad*precio;
descuento=total*.20;
pago=total-descuento;
}
else if(cantidad >=25)
{
Console.WriteLine("Descuento del 20%");
total = cantidad * precio;
descuento = total * .20;
pago = total - descuento;
}
else if (cantidad >= 10)
{
Console.WriteLine("Descuento del 10%");
total = cantidad * precio;
descuento = total * .10;
pago = total - descuento;
}
else
{
Console.WriteLine("No hay descuento =(");
total=cantidad *precio;
descuento = 0;
pago = total - descuento;
}
Console.WriteLine("\n total= {0}\n Descuento={1}\n Pago={2}\n codigo={3}", total, descuento, pago,codigo);
Console.ReadKey();
}

CODIGO EN WINDOWS
private void button1_Click(object sender, EventArgs e)
{
double cantidad, precio, total, descuento, pago,codigo;
cantidad = double.Parse(textBox1.Text);
precio = double.Parse(textBox2.Text);
codigo = double.Parse(textBox6.Text);
if (cantidad > 100)
{
label6.Text=(" 40%");
total = cantidad * precio;
descuento = total * .40;
pago = total - descuento;
textBox3.Text = total.ToString();
textBox4.Text = descuento.ToString();
textBox5.Text = pago.ToString();
textBox7.Text = codigo.ToString();
}
else if (cantidad >= 25)
{
label6.Text = (" 20%");
total = cantidad * precio;
descuento = total * .20;
pago = total - descuento;
textBox3.Text = total.ToString();
textBox4.Text = descuento.ToString();
textBox5.Text = pago.ToString();
textBox7.Text = codigo.ToString();
}
else if (cantidad >= 10)
{
label6.Text = (" 10%");
total = cantidad * precio;
descuento = total * .10;
pago = total - descuento;
textBox3.Text = total.ToString();
textBox4.Text = descuento.ToString();
textBox5.Text = pago.ToString();
textBox7.Text = codigo.ToString();
}
else
{
label6.Text = ("0");
total = cantidad * precio;
descuento = 0;
pago = total - descuento;
textBox3.Text = total.ToString();
textBox4.Text = descuento.ToString();
textBox5.Text = pago.ToString();
textBox7.Text = codigo.ToString();
}
}

No hay comentarios:
Publicar un comentario