Write a program that takes a date as input and outputs the date's season in the northern hemisphere. The input is a string to represent the month and an int to represent the day. Note: End with a newline.

Respuesta :

A program that takes a date as input and outputs the date's season in the northern hemisphere will bear this order

cout << "Winter"

cout << "Spring"

cout << "Summer"

cout << "Autumn"

Complete Code below.

A program that takes a date as input and outputs the date's season in the northern hemisphere

Generally, The dates for each season in the northern hemisphere are:

  • Spring: March 20 - June 20
  • Summer: June 21 - September 21
  • Autumn: September 22 - December 20
  • Winter: December 21 - March 19

And are to be taken into consideration whilst writing the code

Hence

int main() {

string mth;

int dy;

cin >> mth >> dy;

if ((mth == "January" && dy >= 1 && dy <= 31) || (mth == "February" && dy >= 1 && dy <= 29) || (mth == "March" && dy >= 1 && dy <= 19) || (mth == "December" && dy >= 21 && dy <= 30))

cout << "Winter" ;

else if ((mth == "April" && dy >= 1 && dy <= 30) || (mth == "May" && dy >= 1 && dy <= 30) || (mth == "March" && dy >= 20 && dy <= 31) || (mth == "June" && dy >= 1 && dy <= 20))

cout << "Spring" ;

else if ((mth == "July" && dy >= 1 && dy <= 31) || (mth == "August" && dy >= 1 && dy <= 31) || (mth == "June" && dy >= 21 && dy <= 30) || (mth == "September" && dy >= 1 && dy <= 21))

cout << "Summer" ;

else if ((mth == "October" && dy >= 1 && dy <= 31) || (mth == "November" && dy >= 1 && dy <= 30) || (mth == "September" && dy >= 22 && dy <= 30) || (mth == "December" && dy >= 0 && dy <= 20))

cout << "Autumn" ;

else

cout << "Invalid" ;

return 0;

}

For more information on Programming

https://brainly.com/question/13940523