lunes, 23 de febrero de 2009

Ejemplo instruccion switch

using System;
using System.Collections.Generic;
using System.Text;

namespace Aplicacion_consola_menu_restaurante
{
class Program
{
static void Main(string[] args)
{
int opcion,hs,hd,pf,sod,c1,c2,malt;
char sigue;
double total=0.0;



Console.Clear();
total = 0.0;
Console.WriteLine("\n\t\tHamburguesas Patito");
Console.WriteLine("\n\t\t 1) Hamburguesa Sencilla ($30.00)..... ");
Console.WriteLine("\n\t\t 2) Hamburguesa doble ($40.00)........ ");
Console.WriteLine("\n\t\t 3) Papas fritas ($25.00)............. ");
Console.WriteLine("\n\t\t 4) Soda ($15.00)..................... ");
Console.WriteLine("\n\t\t 5) Combo 1 ($45.00).................. ");
Console.WriteLine("\n\t\t 6) Combo 2 ($55.00).................. ");
Console.WriteLine("\n\t\t 7) Malteada ($35.00)................. ");
Console.Write("\n\t\tSelecciona opcion : ");
do
{ Console.SetCursorPosition(35,17);
opcion = int.Parse(Console.ReadLine());

switch (opcion)
{
case 1: Console.SetCursorPosition(55,3);
hs = int.Parse(Console.ReadLine());
total = total + hs * 30.00;
break;
case 2: Console.SetCursorPosition(55, 5);
hd = int.Parse(Console.ReadLine());
total = total + hd * 40.00;
break;
case 3: Console.SetCursorPosition(55, 7);
pf = int.Parse(Console.ReadLine());
total = total + pf * 25.00;
break;
case 4: Console.SetCursorPosition(55, 9);
sod = int.Parse(Console.ReadLine());
total = total + sod * 15.00;
break;
case 5: Console.SetCursorPosition(55, 11);
c1 = int.Parse(Console.ReadLine());
total = total + c1 * 45.00;
break;
case 6: Console.SetCursorPosition(55, 13);
c2 = int.Parse(Console.ReadLine());
total = total + c2 * 55.00;
break;
case 7: Console.SetCursorPosition(55, 15);
malt = int.Parse(Console.ReadLine());
total = total + malt * 30.00;
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 de la orden es {0}", total);
Console.ReadKey();





}
}
}