Advertisement
Guest User

Untitled

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