Classified in Computers
Written at on
English with a size of 3.49 KB.
int opcion=0;
double cantidad, vuelto;
double pago, total = 0;
string[,] fruta = { { 'Manzana', '4.9' }, { 'Pera', '5.5' }, { 'Naranja', '8.6' }, { 'Platano', '2.7' } ,{ 'Fresa', '1.9' } ,{ 'Piña', '2.4' }, { 'Papaya', '4.2' }, { 'Sandia', '3.4' } ,{ 'Durazno', '3.5' } };
String[,] añaFruta = newString[50, 5];
int i=0, j=0;
int añadir = 0,tFruta=0;
do{
do{
i = 0;
Console.Write('_________________________
' +
'FRUTERIA ....
'+
'1) AÑADIR
FRUTA.
');
while (i < 9)
{ Console.Write(i+2+') '+fruta[i,0]+'
');
i++;
}
if(añadir>0)
{j = 11;
i = 0;
tFruta = añadir+9;
while (i < añadir)
{Console.Write(j + ') ' +
añaFruta[i, 0] + '
');
j++;i++;
}
}
else { tFruta = 9; }
Console.Write(tFruta + 2+') Pagar.
');
opcion = int.Parse(Console.ReadLine());
}
while (opcion < 1 || opcion > tFruta+2);
if (opcion == 1)
{
añadir++;
Console.Write('Nombre de la Fruta: ');
añaFruta[añadir-1, 0] = Console.ReadLine();
do
{
Console.Write('Precio de la Fruta: ');
añaFruta[añadir-1, 1] = Console.ReadLine();
} while (Convert.ToDouble(añaFruta[añadir-1], 1]) <= 0);
}
if (opcion > 1 && opcion <= 10)
{
i = 2;
while (i <=10)
{
if (i == opcion)
{
do
{
Console.Write('Cantidad a
comprar [S/' + fruta[i-2, 1] + 'KG]: ');
cantidad = double.Parse(Console.ReadLine());
} while (cantidad <= 0);
total += cantidad * Convert.ToDouble(fruta[i-2 , 1]);
}
i++;
}
}
if (opcion > 10 && opcion
{
i = 11;
j = 0;
while (i < tFruta+2)
{
if (i == opcion)
{
do
{
Console.Write('Cantidad a
comprar [S/' + añaFruta[j, 1] + 'KG]: ');
cantidad = double.Parse(Console.ReadLine());
} while (cantidad <= 0);
total += cantidad * Convert.ToInt32(añaFruta[j, 1]);
}
i++;j++;
}
}
if (opcion==tFruta+2)
{
if (total >= 50 && total < 80)
{
total = total * 0.9;
Console.Write('DCTO del 10% por montos mayores a S/50:
');
}
if (total >= 80 && total < 120)
{
total = total * 0.85;
Console.Write('DCTO del 15 % por montos mayores a S/80:
');
}
if (total >= 120 && total < 150)
{
total = total * 0.8;
Console.Write('DCTO del 20% por montos mayores a S/120:
');
}
if (total >= 150)
{
total = total * 0.75;
Console.Write('DCTO del 25% por montos mayores a S/150:
');
}
Console.Write('Total a Pagar: ' +
total + '
');
do
{Console.Write('Moto con el cual pagar:');
pago =double.Parse(Console.ReadLine());
if (pago < total)
Console.Write('
Monto insuficiente
'); }
} while (pago < total);
vuelto = pago - total;
Console.Write('Vuelto: ' +
vuelto);
Console.ReadKey();
}
while (opcion != tFruta+2);
}}}
Entradas relacionadas: