Advertisement
_CodeBehind

06. Travelling

Nov 26th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         string destination;
  8.         while ((destination = Console.ReadLine()) != "End")
  9.         {
  10.             var destinationPrice = double.Parse(Console.ReadLine());
  11.             while (true)
  12.             {
  13.                 string line = Console.ReadLine();
  14.                 if (line == "End")
  15.                 {
  16.                     return;
  17.                 }
  18.                 destinationPrice -= double.Parse(line);
  19.                 if (destinationPrice <= 0)
  20.                 {
  21.                     break;
  22.                 }
  23.             }
  24.             Console.WriteLine($"Going to {destination}!");
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement