jueves, 26 de febrero de 2009

Hoja 3 Problema2 (consola)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int p1, p2, p3, p4, p5, opcion;
char sigue;
double total = 0.0;


Console.Clear();
total = 0.0;
Console.WriteLine("\n\t\tproductos");
Console.WriteLine("\n\t\t 1) producto 1 $29.80................ ");
Console.WriteLine("\n\t\t 2) producto 2 $45.00................. ");
Console.WriteLine("\n\t\t 3) producto 3 $99.80................. ");
Console.WriteLine("\n\t\t 4) producto 4 $44.90................. ");
Console.WriteLine("\n\t\t 5) producto 5 $68.75................. ");

Console.Write("\n\t\tSelecciona opcion : ");
do
{
Console.SetCursorPosition(35, 17);
opcion = int.Parse(Console.ReadLine());
switch (opcion)
{
case 1: Console.SetCursorPosition(55, 3);
p1 = int.Parse(Console.ReadLine());
total = total + p1 * 29.80;
break;
case 2: Console.SetCursorPosition(55, 5);
p2 = int.Parse(Console.ReadLine());
total = total + p2 * 45.00;
break;
case 3: Console.SetCursorPosition(55, 7);
p3 = int.Parse(Console.ReadLine());
total = total + p3 * 99.80;
break;
case 4: Console.SetCursorPosition(55, 9);
p4 = int.Parse(Console.ReadLine());
total = total + p4 * 44.90;
break;
case 5: Console.SetCursorPosition(55, 11);
p5 = int.Parse(Console.ReadLine());
total = total + p5 * 68.75;
break;

default:
Console.SetCursorPosition(55, 17);
Console.WriteLine("Presiono opcion equivocada ");
break;
}
Console.SetCursorPosition(20, 20);
Console.Write("Desea otro producto s/n : ");
sigue = char.Parse(Console.ReadLine());
}
while (sigue == 's' sigue == 'S');
Console.SetCursorPosition(20, 22);
Console.WriteLine("El total es {0}", total);
Console.ReadKey();
}
}
}

No hay comentarios:

Publicar un comentario