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 Vacation = double.Parse(Console.ReadLine());
- double AveableMoney = double.Parse(Console.ReadLine());
- int Spend = 0;
- int CountDay = 0;
- while(Spend<5 && Vacation> AveableMoney)
- {
- string SpendSave = Console.ReadLine();
- double SpendSaveMoney = double.Parse(Console.ReadLine());
- if (SpendSave =="save")
- {
- AveableMoney += SpendSaveMoney;
- Spend = 0;
- }
- else if(SpendSave == "spend")
- {
- if (AveableMoney - SpendSaveMoney < 0)
- {
- AveableMoney = 0;
- }
- else
- {
- AveableMoney -= SpendSaveMoney;
- }
- Spend++;
- }
- CountDay++;
- }
- if(Spend == 5)
- {
- Console.WriteLine("You can't save the money.");
- Console.WriteLine(CountDay);
- }
- else if(Vacation <= AveableMoney)
- {
- Console.WriteLine($"You saved the money for {CountDay} days.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment