Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 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 _05.Travelling
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. while (true)
  14. {
  15. var destination = Console.ReadLine();
  16. int budjet = int.Parse(Console.ReadLine());
  17. int sum = 0;
  18. if (destination!="End") {
  19. while (true)
  20. {
  21. int money = int.Parse(Console.ReadLine());
  22. sum += money;
  23. if (sum>=budjet)
  24. {
  25. Console.WriteLine($"Going to {destination}!");
  26. sum =0;
  27. break;
  28. }
  29. }
  30. }
  31. else
  32. {
  33. break;
  34. }
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement