using System;
class HelloWorld
{
public static int GetYear()
{
Console.WriteLine("Please enter year: ");
int year = Convert.ToInt32(Console.ReadLine());
return year;
}
public static int GetMonth()
{
Console.WriteLine("Please enter month number (Febuary is 2): ");
int month = Convert.ToInt32(Console.ReadLine());
return month;
}
static string GetMonthName(int month)
{
string[] monthName = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
string monthValue = monthName[month - 1];
return monthValue;
}
public static bool LeapYear(int Year)
{
if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
return true;
else
return false;
}
public static void print(string monthValue, int days, int year, int month)
{
Console.WriteLine("{0} {1} has {2} days\n", year, monthValue, days);
}
static void Main()
{
int[] days = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int[] leapDays = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int monthDays;
while (true)
{
int year = GetYear();
int month = GetMonth();
if (year > 0 && month > 0 && month <= 12)
{
string monthValue = GetMonthName(month);
bool leap = LeapYear(year);
if (leap)
{
monthDays = leapDays[month - 1];
print(monthValue, monthDays, year, month);
}
else
{
monthDays = days[month - 1];
print(monthValue, monthDays, year, month);
}
}
else
{
Console.WriteLine("Invalid Year or Month entered!! Please enter a correct value");
break;
}
}
}
}
I kept getting an error in Github actions, the error was "could not find public class name" even though the Main class is capitalized. I don't know what I'm doing wrong here
When using dotnetfiddle as instructed by my teacher, the error message I received was "Public Main() method is required in a public class" but like I mentioned above, making sure the Main function was capitalized did nothing