Advertisement
angelneychev

06. Travelling

Oct 24th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _45555
  4. {
  5.     class Program
  6.     {
  7.         protected static void Main(string[] args)
  8.         {
  9.             string destination = Console.ReadLine();
  10.             double sumMoney = 0;
  11.             while (true)
  12.             {
  13.                 if (destination == "End")
  14.                 {
  15.                     break;
  16.                 }
  17.                 double budget = double.Parse(Console.ReadLine());
  18.                
  19.                 while (budget > sumMoney)
  20.                 {
  21.                     double money = double.Parse(Console.ReadLine());
  22.                     sumMoney += money;
  23.  
  24.                     if (sumMoney >= budget)
  25.                     {
  26.                         Console.WriteLine($"Going to {destination}!");
  27.                         sumMoney = 0;
  28.                         break;
  29.                     }
  30.                 }
  31.                 destination = Console.ReadLine();
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement