nikolayneykov

Untitled

Oct 12th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.80 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 _124
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double moneyExcursion = double.Parse(Console.ReadLine());
  14.             double moneyDzesy = double.Parse(Console.ReadLine());
  15.             string saveSpend = Console.ReadLine();
  16.             double currentMoney = double.Parse(Console.ReadLine());
  17.  
  18.             int countDays = 1;
  19.             int countDaysSpend = 0;
  20.             do
  21.             {
  22.  
  23.                 if (saveSpend == "save")
  24.                 {
  25.                     moneyDzesy += currentMoney;
  26.                     countDaysSpend = 0;
  27.                     if (moneyDzesy >= moneyExcursion)
  28.                     {
  29.                         Console.WriteLine($"You saved the money for {countDays} days.");
  30.                         break;
  31.                     }
  32.  
  33.                 }
  34.                 else if (saveSpend == "spend")
  35.                 {
  36.                     countDaysSpend++;
  37.  
  38.                     if (moneyDzesy <= currentMoney)
  39.                     {
  40.                         moneyDzesy = 0;
  41.                     }
  42.                     else
  43.                     {
  44.                         moneyDzesy -= currentMoney;
  45.                     }
  46.                     if (countDaysSpend == 5)
  47.                     {
  48.                         Console.WriteLine("You can't save the money.");
  49.                         Console.WriteLine(countDays);
  50.                         break;
  51.                     }
  52.                 }
  53.                 saveSpend = Console.ReadLine();
  54.                 currentMoney = double.Parse(Console.ReadLine());
  55.                 countDays++;
  56.  
  57.  
  58.             } while (moneyDzesy < moneyExcursion);
  59.  
  60.  
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment