Advertisement
bullit3189

Shopping Mania 2nd option

Nov 18th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _13ShoppingMania
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double budget = double.Parse(Console.ReadLine());
  14.  
  15. double spentMoney = 0;
  16. int clothesCounter = 0;
  17.  
  18. while (budget >0)
  19. {
  20. string command = Console.ReadLine();
  21.  
  22. if (command == "enough")
  23. {
  24. break;
  25. }
  26.  
  27.  
  28. if (command == "enter")
  29. {
  30. command = Console.ReadLine();
  31.  
  32. while (command != "leave")
  33. {
  34. double money = double.Parse(command);
  35.  
  36. if (money>budget)
  37. {
  38. Console.WriteLine("Not enough money.");
  39. }
  40. else
  41. {
  42. clothesCounter++;
  43. spentMoney += money;
  44. budget -= money;
  45. }
  46. if (budget<=0)
  47. {
  48. break;
  49. }
  50. command = Console.ReadLine();
  51. }
  52.  
  53. }
  54. }
  55. Console.WriteLine($"For {clothesCounter} clothes I spent {spentMoney} lv and have {budget} lv left.");
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement