Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions 2-variables/10-YearOfTheX.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
// Year of the X 📆
// Codédex

using System;

class YearOfTheX
class Program
{
static void Main()
{
Console.WriteLine("What year were you born?");

string input = Console.ReadLine();
int birthYear = int.Parse(input);

int cycle = 12;

int yearsUntilZodiac = (cycle - ((currentYear - birthYear) % cycle)) % cycle;

Console.WriteLine("Your zodiac year comes again in " + yearsUntilZodiac + " year(s)!");
}
}
static void Main()
{
Console.Write("Enter your birth year: ");
int birthYear = int.Parse(Console.ReadLine());

int yearsPassed = DateTime.Now.Year - birthYear;
int yearsUntilNextZodiac = (12 - yearsPassed % 12) % 12;
Console.WriteLine(yearsUntilNextZodiac);
}
}