Advertisement
Guest User

travelling

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