Advertisement
jkonova

Untitled

Aug 5th, 2021
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Travelling
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string destination = Console.ReadLine();
  10.  
  11.             string outputCurrentDestination = "";
  12.             string outputAllDestination = "";
  13.             double minBudget = 0;
  14.             double currentSaveAmount = 0;
  15.  
  16.             while (destination != "End")
  17.             {
  18.                 minBudget = int.Parse(Console.ReadLine());
  19.  
  20.                 while (minBudget > 0)
  21.                 {
  22.                     string command = Console.ReadLine();
  23.                     if (command == "End")
  24.                     {
  25.                         Console.WriteLine(outputAllDestination);
  26.                         return;
  27.                     }
  28.                     currentSaveAmount = int.Parse(command);
  29.                     minBudget -= currentSaveAmount;
  30.                 }
  31.                 outputCurrentDestination = "Going to " + destination + "!" + "\n";
  32.                 outputAllDestination += outputCurrentDestination;
  33.                 destination = Console.ReadLine();
  34.             }
  35.             if (destination == "End")
  36.             {
  37.                 Console.WriteLine(outputAllDestination);
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement