C# Rechner
Hey, hab da mal ne Frage. Undzwar soll ich in C# einen Taschenrechner Programmieren. Nun bin ich so weit, dass er grob funktioniert. Aber nur mit 2 Werten. Nun will ich aber mit dem Ergebnis direkt weiterrechnen können. Hat da jmd ne Idee?
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("**** Tippe die erste Zahl ein *****");
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("**** Tippe die zweite Zahl ein *****");
int y = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("**** Tippe 1 für Addition *****");
Console.WriteLine("**** Tippe 2 für Subtraktion *****");
Console.WriteLine("**** Tippe 3 für Multiplikation *****");
Console.WriteLine("**** Tippe 4 für Division *****");
int z = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("**** Ergebnis: *****");
switch (z)
{
case 1:
Console.WriteLine(x + y);
break;
case 2:
Console.WriteLine(x - y);
break;
case 3:
Console.WriteLine(x * y);
break;
case 4:
Console.WriteLine(x / y);
break;
}
{
Console.WriteLine("** Drücke Enter zum beenden **");
Console.ReadLine();
}
}
}
}
programmieren,
C Sharp,
cmd,
Taschenrechner,
Visual Studio