using System;
namespace ciclo_for_2
{
internal class ENTRADASCICLOFOR
{
static void Main(string[] args)
{
double precioEntrada = 100000;
Console.Title = "CICLO FOR";
Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Black;
Console.Clear();
Console.WriteLine("EL VALOR DE LA BOLETA PARA EL CONCIERTO DEL FERCHO ES DE $100.000 PESOS");
Console.WriteLine("- DESCUENTO POR COMPRA");
Console.WriteLine("- LA COMPRA DE DOS BOLETAS: 10%");
Console.WriteLine("- LA COMPRA DE TRES BOLETAS: 15%");
Console.WriteLine("- LA COMPRA DE CUATRO BOLETAS: 20%");
Console.WriteLine();
Console.Write("INGRESE LA CANTIDAD DE ENTRADAS QUE DESEA COMPRAR (MAXIMO 4): ");
int cantidad = int.Parse(Console.ReadLine());
if (cantidad < 1 || cantidad > 4)
{
Console.WriteLine("ERROR: SOLO SE PERMITEN COMPRAR ENTRE 1 Y 4 ENTRADAS.");
}
double subtotal = 0;
double descuento = 0;
// Ciclo FOR
for (int i = 1; i <= cantidad; i++)
{
subtotal += precioEntrada;
}
// Aplicar descuento
if (cantidad == 2)
{
descuento = 0.10;
}
else if (cantidad == 3)
{
descuento = 0.15;
}
else if (cantidad == 4)
{
descuento = 0.20;
}
double montoDescuento = subtotal * descuento;
double totalAPagar = subtotal - montoDescuento;
Console.WriteLine();
Console.WriteLine("Subtotal: $" + subtotal);
Console.WriteLine("Descuento: $" + montoDescuento);
Console.WriteLine("Total a pagar: $" + totalAPagar);
Console.Write("\n¿Desea procesar otro cliente? (s/n): ");
Console.WriteLine();
Console.WriteLine("Gracias por tu compra.");
Console.ReadKey();
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: