Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Attempting to validate input, month < 1 || month > 13. First invalid brings invalid input message, valid input brings up invalid input message, second

Attempting to validate input, month < 1 || month > 13. First invalid brings invalid input message, valid input brings up invalid input message, second valid input works.

while (!done)

{

if (month == 0 && year == 0)

{

done = true;

year = timeinfo->tm_year + 1900;

days = numberOfDays(timeinfo->tm_mon + 1, year);

cout << " The current month " << months[timeinfo -> tm_mon] << " "

<< year << " has " << days << " days.";

cout << endl;

break;

}

else if (month < 1 || month > 12)

{

cout << " Invalid month entry, try again.";

cout << " Enter the month as (1-12), space, and year as (2017)." << endl;

cin >> month;

cin >> year;

}

else

{

days = numberOfDays(month, year);

cout << " " << days << " days" << endl;

}

if (!done)

{

cout << " Enter the month as (1-12), space, and year as (2017).";

cout << " To quit, enter 0 for month and 0 for year." << endl;

cout << endl;

cin >> month;

cin >> year;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions