Advertisement
Guest User

Untitled

a guest
Jan 12th, 2016
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. namespace Övning_7._4._2___Banksimulator
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. decimal saldo = 0;
  8. while (true)
  9. {
  10. Console.WriteLine("Banken");
  11. Console.WriteLine("[I]nsättning");
  12. Console.WriteLine("[U]ttag");
  13. Console.WriteLine("[S]aldo");
  14. Console.WriteLine("[A]vsluta");
  15. string Inmatning = Console.ReadLine();
  16.  
  17.  
  18.  
  19.  
  20. switch (Inmatning.ToLower())
  21. {
  22. case "i":
  23. decimal insättning;
  24. Console.Write("Mata in belopped du vill sätta in: ");
  25. if (Decimal.TryParse(Console.ReadLine(), out insättning))
  26. saldo += insättning;
  27. else
  28. Console.WriteLine("Insättning kunde ej göras pga att du inte skrev ett giltigt tal.");
  29. break;
  30. case "u":
  31. decimal uttag;
  32. Console.Write("Mata in belopped du vill ta ut: ");
  33. if (Decimal.TryParse(Console.ReadLine(), out uttag))
  34. saldo -= uttag;
  35. else
  36. Console.WriteLine("Uttag kunde ej göras pga att du inte skrev ett giltigt tal.");
  37. break;
  38. case "s":
  39. Console.WriteLine($"Ditt saldo är {saldo:C}");
  40. break;
  41. case "a":
  42. break;
  43. break;
  44. default:
  45. Console.WriteLine("Ogiltigt kommando");
  46. break;
  47. }
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement