since im new to C#, even though i have coded in C before, i still have a question on how I go about to execute the part where i ask the user to enter a set of inputs after a program has already been run.
The following program prints a calendar with the specified number of months, but i need help writing another line of code that would ask the user to enter the month, year and number of months to be printed, after the user has already inputed the values once. Do i have to do some type of looping in my main function or do i have to do it on the method above my main function ?
static void GenMonth(int month, int year)
{
int daycode, ndim;
PrintHeader(month, year);
ndim=GetNDIM(month,year);
int day=1;
daycode = GetDayCode(month, day, year);
int a,i;
for(a=1;a<=daycode;a++)
{
Console.Write(" ");
}
for (i = 1; i <= GetNDIM(month, year); i++)
{
Console.Write("{0,4}", i);
if (((i + daycode) % 7) == 0)
Console.Write("\n");
}
daycode = GetDayCode(month, day, year);
if (daycode == 6)
{
Console.Write("\n");
}
}
static void Main(string[] args)
{
Console.WriteLine("please enter m,y,n: \n");
string input = Console.ReadLine();
string[] split = input.Split(' ');
int month = Int32.Parse(split[0]);
int year = Int32.Parse(split[1]);
int numberOfMonths = Int32.Parse(split[2]);
int i=0;
for (i = 0; i < numberOfMonths; i++)
{
GenMonth(month, year);
month++;
Console.Write("\n \n");
}
if (month > 12)
{
month = 1;
year++;
}
Console.ReadKey();
}