Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _124
- {
- class Program
- {
- static void Main(string[] args)
- {
- double moneyExcursion = double.Parse(Console.ReadLine());
- double moneyDzesy = double.Parse(Console.ReadLine());
- string saveSpend = Console.ReadLine();
- double currentMoney = double.Parse(Console.ReadLine());
- int countDays = 1;
- int countDaysSpend = 0;
- do
- {
- if (saveSpend == "save")
- {
- moneyDzesy += currentMoney;
- countDaysSpend = 0;
- if (moneyDzesy >= moneyExcursion)
- {
- Console.WriteLine($"You saved the money for {countDays} days.");
- break;
- }
- }
- else if (saveSpend == "spend")
- {
- countDaysSpend++;
- if (moneyDzesy <= currentMoney)
- {
- moneyDzesy = 0;
- }
- else
- {
- moneyDzesy -= currentMoney;
- }
- if (countDaysSpend == 5)
- {
- Console.WriteLine("You can't save the money.");
- Console.WriteLine(countDays);
- break;
- }
- }
- saveSpend = Console.ReadLine();
- currentMoney = double.Parse(Console.ReadLine());
- countDays++;
- } while (moneyDzesy < moneyExcursion);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment