Advertisement
Dianov

Nested Loops - Lab (05. Travelling)

Dec 30th, 2020
669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Travelling
  8.  
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             while (true)
  15.             {
  16.                 double sum = 0;
  17.                 string destination = Console.ReadLine();
  18.                 if (destination == "End")
  19.                 {
  20.                     break;
  21.                 }
  22.                 double neededMoney = double.Parse(Console.ReadLine());
  23.                 while (sum < neededMoney)
  24.                 {
  25.                     double input = double.Parse(Console.ReadLine());
  26.                     sum += input;
  27.                 }
  28.                 Console.WriteLine($"Going to {destination}!");
  29.             }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement