// CalendarAssistant.cpp : main project file.

#include "stdafx.h"

using namespace System;

int GetYear();
int GetMonth();
int GetDay(int year, int month);
void DisplayDate(int year, int month, int day);

int main(array<System::String ^> ^args)
{
	Console::WriteLine(L"Welcome to your calendar assistant");
	for (int count = 1; count <= 5; count++)
	{
		Console::Write(L"\nPlease enter date ");
		Console::WriteLine(count);
		int year = GetYear();
		int month = GetMonth();
		int day = GetDay(year, month);

		Console::Write(L"Press B (break), C (continue), or ");
		Console::Write(L"anything else to display date ");
		String ^ input = Console::ReadLine();
		if (input->Equals(L"B"))
		{
			break;
		}
		else if (input->Equals(L"C"))
		{
			continue;
		}
		DisplayDate(year, month, day);
		}
    return 0;
}

int GetYear()
{
    Console::Write(L"Year? ");
    String ^ input = Console::ReadLine();
	int year = Convert::ToInt32(input);
    return year;
}

int GetMonth()
{
    int month = 0;
    do
    {
        Console::Write(L"Month [1 to 12]? ");
        String ^ input = Console::ReadLine();
		month = Convert::ToInt32(input);
    }
    while (month < 1 || month > 12);
    return month;
}

int GetDay(int year, int month)
{
	int day = 0;
	int maxDay;

	if (month == 4 || month == 6 || month == 9 || month == 11)
	{
		maxDay = 30;
	}
	else if (month == 2)
	{
		bool isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
		if (isLeapYear)
		{
			maxDay = 29;
		}
		else
		{
			maxDay = 28;
		}
	}
	else
	{
		maxDay = 31;
	}

	do
    {
        Console::Write(L"Day [1 to ");
        Console::Write(maxDay);
        Console::Write(L"]? ");
        String ^ input = Console::ReadLine();
		day = Convert::ToInt32(input);
    }
    while (day < 1 || day > maxDay);
    return day;
}

void DisplayDate(int year, int month, int day)
{
	Console::WriteLine(L"\nThis is the date you entered:");
    Console::Write(year);
    Console::Write(L"-");
    Console::Write(month);
    Console::Write(L"-");
    Console::Write(day);
    Console::WriteLine();

	switch (month)
	{
		case 1:  Console::Write(L"January");   break;
		case 2:  Console::Write(L"February");  break;
		case 3:  Console::Write(L"March");     break;
		case 4:  Console::Write(L"April");     break;
		case 5:  Console::Write(L"May");       break;
		case 6:  Console::Write(L"June");      break;
		case 7:  Console::Write(L"July");      break;
		case 8:  Console::Write(L"August");    break;
		case 9:  Console::Write(L"September"); break;
		case 10: Console::Write(L"October");   break;
		case 11: Console::Write(L"November");  break;
		case 12: Console::Write(L"December");  break;
		default: Console::Write(L"Unknown");   break;
	}

	switch (month)
	{
		case 12:
		case 1:
		case 2:  Console::WriteLine(L" [Winter]"); break;
		case 3:
		case 4:
		case 5:  Console::WriteLine(L" [Spring]"); break;
		case 6:
		case 7:
		case 8:  Console::WriteLine(L" [Summer]"); break;
		case 9:
		case 10:
		case 11: Console::WriteLine(L" [Fall]"); break;
	}
}


 int n; 
    do 
    {
        String ^ input = Console::ReadLine();
		n = Convert::ToInt32 ->ToInt32(0); 
    } 
    while (n > 100);



















