Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Övning_7._4._2___Banksimulator
- {
- class Program
- {
- static void Main(string[] args)
- {
- decimal saldo = 0;
- while (true)
- {
- Console.WriteLine("Banken");
- Console.WriteLine("[I]nsättning");
- Console.WriteLine("[U]ttag");
- Console.WriteLine("[S]aldo");
- Console.WriteLine("[A]vsluta");
- string Inmatning = Console.ReadLine();
- switch (Inmatning.ToLower())
- {
- case "i":
- decimal insättning;
- Console.Write("Mata in belopped du vill sätta in: ");
- if (Decimal.TryParse(Console.ReadLine(), out insättning))
- saldo += insättning;
- else
- Console.WriteLine("Insättning kunde ej göras pga att du inte skrev ett giltigt tal.");
- break;
- case "u":
- decimal uttag;
- Console.Write("Mata in belopped du vill ta ut: ");
- if (Decimal.TryParse(Console.ReadLine(), out uttag))
- saldo -= uttag;
- else
- Console.WriteLine("Uttag kunde ej göras pga att du inte skrev ett giltigt tal.");
- break;
- case "s":
- Console.WriteLine($"Ditt saldo är {saldo:C}");
- break;
- case "a":
- break;
- break;
- default:
- Console.WriteLine("Ogiltigt kommando");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement