Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Vacation
- {
- class Program
- {
- static void Main(string[] args)
- {
- double sumVacation = double.Parse(Console.ReadLine());
- double moneyJesie = double.Parse(Console.ReadLine());
- int days = 1;
- while (moneyJesie < sumVacation)
- {
- string action = Console.ReadLine();
- double sumSpentSaved = double.Parse(Console.ReadLine());
- if (action == "save")
- {
- moneyJesie = moneyJesie + sumSpentSaved;
- }
- else if (action == "spend")
- {
- if (sumSpentSaved > moneyJesie)
- {
- moneyJesie = 0;
- }
- else
- {
- moneyJesie -= sumSpentSaved;
- }
- }
- if (days == 5 && action == "spend")
- {
- Console.WriteLine("You can't save the money.");
- Console.WriteLine(days);
- break;
- }
- if (moneyJesie >= sumVacation)
- {
- Console.WriteLine($"You saved the money for {days} days.");
- break;
- }
- days++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment