You are on page 1of 7

Isaac Bernal

Fundamentals of Programming 1
Professor Lara
10/7/21

Analysis
In this program, we are solving whether certain dates correlate with a specific
season. A month and day are inputted by the user and an output text will tell it what
season that date belongs to.

Variables: There are only two variables used in this program. The first variable is named
“month”. The second variable is named “day”. The month variable is under a string
variable type. And the day variable is under an integer variable type.

Data Validation: The month and day variables will be put under multiple “if” statements
to determine the dates seasons. Most “if” statements will only look for the month inputs
and other statements will need to look at the day.
/*Isaac Bernal
Fundamentals of Programming 1
Professor Lara
10/7/21
In this program, we are solving whether certain dates correlates with a
specific season. A month and day is inputted by the user and an output
text will tell it what season that date belongs to.*/

#include <iostream>
#include <string>
using namespace std;

int main() {
string month;//variable used for the input of month
int day;//variable used for the input of day

cout << "\t...Welcome to How to Tell the Seasons...\n\n";


cout << "Please enter a month:\n" ;
cin >> month;
cout << "\nPlease enter a day:\n" ;
cin >> day;
if (day >= 31)//the use of if statement to make sure the user doesn't
include an invalid date
{
cout << "\n**Error** Please Enter Correct Day: \n";
cin >> day;
}

if ((month == "March" || month == "march") && (day >= 20))


{cout << "\nThat date " << month << ' ' << day << " is in the spring
season." ;}// if and else if statements used throughout the code to make
sure the correct output is with a certain input.

else if (month == "April" || month == "april")


{cout << "\nThat date " << month << ' ' << day << " is in the spring
season." ;}
else if (month == "May" || month == "may")
{cout << "\nThat date " << month << ' ' << day << " is in the spring
season." ;}

else if ((month == "June" || month == "june") && (day <= 20))


{cout << "\nThat date " << month << ' ' << day << " is in the spring
season." ;}

else if ((month == "June" || month == "june") && (day >= 21))


{cout << "\nThat date " << month << ' ' << day << " is in the summer
season." ;}

else if (month == "July" || month == "july")


{cout << "\nThat date " << month << ' ' << day << " is in the summer
season." ;}

else if (month == "August" || month == "august")


{cout << "\nThat date " << month << ' ' << day << " is in the summer
season." ;}

else if ((month == "September" || month == "september") && (day <= 21))


{cout << "\nThat date " << month << ' ' << day << " is in the summer
season." ;}

else if ((month == "September" || month == "september") && (day >= 22))


{cout << "\nThat date " << month << ' ' << day << " is in the autumn
season." ;}

else if (month == "October" || month == "october")


{cout << "\nThat date " << month << ' ' << day << " is in the autumn
season." ;}

else if (month == "November" || month == "november")


{cout << "\nThat date " << month << ' ' << day << " is in the autumn
season." ;}

else if ((month == "December" || month == "december") && (day <= 20))


{cout << "\nThat date " << month << ' ' << day << " is in the autumn
season." ;}
else if ((month == "December" || month == "december") && (day >= 21))
{cout << "\nThat date " << month << ' ' << day << " is in the winter
season." ;}

else if (month == "January" || month == "january")


{cout << "\nThat date " << month << ' ' << day << " is in the winter
season." ;}

else if (month == "February" || month == "february")


{cout << "\nThat date " << month << ' ' << day << " is in the winter
season." ;}

else if ((month == "March" || month == "march") && (day <= 19))


{cout << "\nThat date " << month << ' ' << day << " is in the winter
season." ;}

return 0;
}

You might also like