Advertisement
bullit3189

Shopping Mania

Nov 5th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5. public static void Main()
  6. {
  7. int startMoney = int.Parse(Console.ReadLine());
  8. string command = Console.ReadLine();
  9.  
  10. int clothesCounter =0;
  11. int moneyLeft =startMoney;
  12. int spentMoney=0;
  13.  
  14.  
  15.  
  16. while (true) // while (spentMoney<=startMoney)
  17. {
  18.  
  19.  
  20. if (command == "enter")
  21. {
  22. command = Console.ReadLine();
  23.  
  24. while (command != "leave")
  25. {
  26. int currSpentMoney = int.Parse(command);
  27. if (currSpentMoney > moneyLeft)
  28. {
  29. Console.WriteLine("Not enough money.");
  30. }
  31. else
  32. {
  33. moneyLeft -= currSpentMoney;
  34. spentMoney += currSpentMoney;
  35. clothesCounter ++;
  36. if (spentMoney >= startMoney)
  37. {
  38. Console.WriteLine("For {0} clothes I spent {1} lv and have {2} lv left.",clothesCounter,spentMoney,moneyLeft);
  39. return;
  40. }
  41. }
  42. command = Console.ReadLine();
  43. }
  44. if (command == "leave")
  45. {
  46. command = Console.ReadLine();
  47. {
  48. while (command!= "enter")
  49. {
  50.  
  51.  
  52. if (command == "enough")
  53. {
  54. Console.WriteLine("For {0} clothes I spent {1} lv and have {2} lv left.",clothesCounter,spentMoney,moneyLeft);
  55. return;
  56. }
  57. command = Console.ReadLine();
  58. }
  59. }
  60. }
  61. }
  62. }
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement