Last active
July 13, 2018 02:14
-
-
Save d630/5347b1f623aa722c0a4d8afd01418917 to your computer and use it in GitHub Desktop.
Tag 6: Konto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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