Guest User

Untitled

a guest
Jun 24th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp17
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. decimal budget = decimal.Parse(Console.ReadLine());
  10. decimal amountSpent = 0;
  11. decimal price = 0;
  12.  
  13.  
  14. while (budget > 0)
  15. {
  16. string title = Console.ReadLine();
  17. switch (title)
  18. {
  19. case ("OutFall 4"):
  20. price = 39.99M;
  21. if (budget >= price)
  22. {
  23. Console.WriteLine("Bought OutFall 4");
  24. budget -= price;
  25. amountSpent += price;
  26. }
  27. else if (budget < price) Console.WriteLine("Too Expensive");
  28. break;
  29. case ("CS:OG"):
  30. price = 15.99M;
  31. if (budget >= price)
  32. {
  33. Console.WriteLine("Bought CS:OG");
  34. budget -= price;
  35. amountSpent += price;
  36. }
  37. else if (budget < price) Console.WriteLine("Too Expensive");
  38. break;
  39. case ("Zplinter Zell"):
  40. price = 19.99M;
  41. if (budget >= price)
  42. {
  43. Console.WriteLine("Bought Zplinter Zell");
  44. budget -= price;
  45. amountSpent += price;
  46. }
  47. else if (budget < price) Console.WriteLine("Too Expensive");
  48. break;
  49. case ("Honored 2"):
  50. price = 59.99M;
  51. if (budget >= price)
  52. {
  53. Console.WriteLine("Bought Honored 2");
  54. budget -= price;
  55. amountSpent += price;
  56. }
  57. else if (budget < price) Console.WriteLine("Too Expensive");
  58. break;
  59. case ("RoverWatch"):
  60. price = 29.99M;
  61. if (budget >= price)
  62. {
  63. Console.WriteLine("Bought RoverWatch");
  64. budget -= price;
  65. amountSpent += price;
  66. }
  67. else if (budget < price) Console.WriteLine("Too Expensive");
  68. break;
  69. case ("RoverWatch Origins Edition"):
  70. price = 39.99M;
  71. if (budget >= price)
  72. {
  73. Console.WriteLine("Bought RoverWatch Origins Edition");
  74. budget -= price;
  75. amountSpent += price;
  76. }
  77. else if (budget < price) Console.WriteLine("Too Expensive");
  78. break;
  79. case ("Game Time"):
  80. {
  81. Console.WriteLine($"Total spent: ${amountSpent:F02}. Remaining: ${budget:F02}");
  82. }
  83. return;
  84. default:
  85. Console.WriteLine("Not Found");
  86. break;
  87. }
  88. }
  89. Console.WriteLine("Out of money!");
  90. }
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment