Skip to content

Instantly share code, notes, and snippets.

@d630
Last active July 13, 2018 02:14
Show Gist options
  • Save d630/5347b1f623aa722c0a4d8afd01418917 to your computer and use it in GitHub Desktop.
Save d630/5347b1f623aa722c0a4d8afd01418917 to your computer and use it in GitHub Desktop.
Tag 6: Konto
namespace csharp
{
public class Konto
{
private double kontostand;
public Konto()
{
this.kontostand = 5000.00;
}
public double Kontostand {
get
{
return this.kontostand;
}
set
{
this.kontostand = value;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace csharp
{
public class Program
{
static void Main(string[] args)
{
Konto k = new Konto();
List<double> a = new List<double>();
int n;
double b;
double summeA = 0.0;
double summeE = 0.0;
do
{
Console.Write("Einzahlen (1), Auszahlen (2), Beenden (0): " );
n = int.Parse(Console.ReadLine());
switch (n)
{
case 1:
Console.Write("Betrag: ");
b = double.Parse(Console.ReadLine());
k.Kontostand += b;
a.Add(b);
summeE += b;
break;
case 2:
Console.Write("Betrag: ");
b = double.Parse(Console.ReadLine());
k.Kontostand -= b;
a.Add(-b);
summeA += -b;
break;
}
Console.WriteLine("Kontostand: {0:F2}", k.Kontostand);
} while (n != 0);
foreach (double aa in a)
Console.WriteLine("{0:F2}", aa);
Console.WriteLine("Einzahlungen: {0:F2}\nAuszahlungen: {1:F2}", summeE, summeA);
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment