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 _01.Piggy_Bank
- {
- class Piggy_Bank
- {
- static void Main(string[] args)
- {
- //• On the first line you will be given an integer – the price of the tank.
- decimal priceOfTheTank = decimal.Parse(Console.ReadLine());
- //• On the second line you will be given the number of party days in a month.
- uint partyDays = uint.Parse(Console.ReadLine());
- uint daysInMonth = 30;
- uint normalDays = daysInMonth - partyDays;
- uint normalDaysSaves = normalDays * 2;
- uint partyDaysSpend = partyDays * 5;
- uint averagePerMonth = normalDaysSaves - partyDaysSpend;
- double monthsNeeded = Math.Ceiling((double)priceOfTheTank / averagePerMonth);
- double neededYears = Math.Floor(monthsNeeded / 12.0);
- double monthsLeft = Math.Ceiling(monthsNeeded % 12);
- if (normalDaysSaves > partyDaysSpend)
- {
- Console.WriteLine("{0} years, {1} months", neededYears, monthsLeft);
- }
- else
- {
- Console.WriteLine("never");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment