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