Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ please Part 1: Complete the survey. Part 2: Write a program that takes a date as input and outputs the date's season. The input

C++ please

Part 1: Complete the survey.

Part 2: 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 invalid, 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

#include #include using namespace std;

int main() { string inputMonth; int inputDay; cin >> inputMonth; cin >> inputDay;

if ((inputMonth == "january" && inputDay >= 1 && inputDay <= 31) || (inputMonth == "february" && inputDay >= 1 && inputDay <= 29) || (inputMonth == "march" && inputDay >= 1 && inputDay <= 19) || (inputMonth == "december" && inputDay >= 21 && inputDay <= 30)) cout << "winter" << endl; else if ((inputMonth == "april" && inputDay >= 1 && inputDay <= 30) || (inputMonth == "may" && inputDay >= 1 && inputDay <= 30) || (inputMonth == "march" && inputDay >= 20 && inputDay <= 31) || (inputMonth == "june" && inputDay >= 1 && inputDay <= 20)) cout << "spring" << endl; else if ((inputMonth == "july" && inputDay >= 1 && inputDay <= 31) || (inputMonth == "august" && inputDay >= 1 && inputDay <= 31) || (inputMonth == "june" && inputDay >= 21 && inputDay <= 30) || (inputMonth == "september" && inputDay >= 1 && inputDay <= 21)) cout << "summer" << endl; else if ((inputMonth == "october" && inputDay >= 1 && inputDay <= 31) || (inputMonth == "november" && inputDay >= 1 && inputDay <= 30) || (inputMonth == "september" && inputDay >= 22 && inputDay <= 30) || (inputMonth == "december" && inputDay >= 0 && inputDay <= 20)) cout << "autumn" << endl; else cout << "invalid" << endl; return 0; }

what am i doing wrong i am getting invalid

Output differs. See highlights below.

Input

April 11

Your output

invalid

Expected output

spring

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

More Books

Students also viewed these Databases questions

Question

What would your clients like you to do more of/less of?

Answered: 1 week ago