90.5k views
1 vote
3.19 LAB: Seasons In C++ Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day. Ex: If the input is: April 11 the output is: Spring In addition, check if the string and int are valid (an actual month and day). Ex: If the input is: Blue 65 the output is: Invalid The dates for each season are: Spring: March 20 - June 20 Summer: June 21 - September 21 Autumn: September 22 - December 20 Winter: December 21 - March 19

User Tamlok
by
5.5k points

2 Answers

3 votes

Answer: sorry this is in coral

integer inputMonth

integer inputDay

inputMonth = Get next input

inputDay = Get next input

if (inputMonth == 1 and inputDay >= 1 and inputDay <= 31)

Put "winter" to output

elseif (inputMonth == 2 and inputDay >= 1 and inputDay <= 29)

Put "winter" to output

elseif (inputMonth == 3)

if (inputDay >= 1 and inputDay <= 19)

Put "winter" to output

elseif (inputDay > 19 and inputDay <= 31)

Put "spring" to output

elseif (inputDay >=32)

Put "invalid" to output

elseif (inputMonth == 4 and inputDay >=1 and inputDay <= 30)

Put "spring" to output

elseif (inputMonth == 5 and inputDay >=1 and inputDay <= 31)

Put "spring" to output

elseif (inputMonth == 6)

if (inputDay >=1 and inputDay <= 20)

Put "spring" to output

elseif (inputDay >= 21 and inputDay <= 30)

Put "summer" to output

elseif (inputDay >=31)

Put "invalid" to output

elseif (inputMonth == 7 and inputDay >=1 and inputDay <= 31)

Put "summer" to output

elseif (inputMonth == 8 and inputDay >=1 and inputDay <= 30)

Put "summer" to output

elseif (inputMonth == 9)

if (inputDay >=1 and inputDay <=21)

Put "summer" to output

elseif (inputDay >= 22 and inputDay <=30)

Put "autumn" to output

elseif (inputDay >=31)

Put "invalid" to output

elseif (inputMonth == 10 and inputDay >=1 and inputDay <= 31)

Put "autumn" to output

elseif (inputMonth == 11 and inputDay >=1 and inputDay <= 30)

Put "autumn" to output

elseif (inputMonth == 12)

if (inputDay <= 0)

Put "invalid" to output

elseif (inputDay >= 1 and inputDay <= 20)

Put "autumn" to output

elseif (inputDay >=21 and inputDay<=31)

Put"winter" to output

else

Put "invalid" to output

Step-by-step explanation:

User Cw
by
5.2k points
2 votes

Answer:

#include <iostream>

#include <string>

using namespace std;

int main()

Step-by-step explanation:

User Loviji
by
4.8k points