hope all is well. I was working on some code (C++) that would determine the season depending on the users input. The user is meant to type in a valid month and date in a year and from that the code is supposed to determine the season. Per instructions provided by my professor:
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
I was working on Spring for now, and this is the code I have. Just a little heads up, when inputting values March 20 - March 31, the code runs to my expectation and prints what is being looked for. However, when I type in any value such as June 1 - June 20 the program compiles, but it does not produce an output.
Here is the link to my code: https://repl.it/repls/FlippantAgileTheory
And here is the code:
using namespace std;
int main() {
string inputMonth;
int inputDay;
cin >> inputMonth;
cin >> inputDay;
if (inputMonth == "March" || inputMonth == "June"){
if (inputMonth == "March"){
if (inputDay > 19 && inputDay < 32){
cout << "Spring\n";
}
else if (inputMonth == "June"){ // this is the aspect of the code that doesn't work
if ((inputDay > 0) && (inputDay < 21)){
cout << "Spring\n";
}
}
}
} }
Aucun commentaire:
Enregistrer un commentaire