In: Computer Science
Pseudocode please:
Assignment6B: For this assignment, you should ask the user for a day and a month, then determine what season it is based on that input. Write a method that takes in a month and day and returns which season it is (“Spring”, “Summer”, “Fall”, “Winter”). Your main method should be the only one that includes a print statement. Note the first days of each season:
• March 19th – Spring
• June 20st – Summer
• September 22nd - Fall
• December 21st - Winter
Sample Output #1:
Enter a month: 6
Enter a day: 19
It is Spring!
Sample Output #2:
Enter a month: 6
Enter a day: 20
It is Summer!
Sample Output #3:
Enter a month: 2
Enter a day: 27
It is Winter!
Sample Output #4:
Enter a month: 7
Enter a day: 19
It is Summer!
Answer:-
Step1:- Ask the user for the month and date.
int m,d;
printf("Enter an month: ");
scanf("%d", &m);
printf("Enter an day: ");
scanf("%d", &d);
Step2:- We can use a switch statement for this type of question,
Step3:- To check the month first using switch & apply the if-else condition to check the date of season condition in each month.
Step4:-Check months, then date and print output
Likewise
input m
input d
switch(m)
case(1)
print "It is Winter!"
break
case(2)
print "It is Winter!"
break
case(3)
if d<19
print "It is Winter!"
else
print "It is Spring!"
break
case(4)
print "It is Spring!"
break
case(5)
print "It is Spring!"
break
case(6)
if d<20
print "It is Spring!"
else
print "It is Summer!"
break
case(7)
print "It is Summer!"
break
case(8)
print "It is Summer!"
break
case(9)
if d<22
print "It is Summer!"
else
print "It is Fall!"
break
case(10)
print "It is Fall!"
break
case(11)
print "It is Fall!"
break
case(12)
if d<21
print "It is Fall!"
else
print "It is Winter!"
break
Code for your refernce in c language:-
#include <stdio.h>
int main()
{
int m,d;
   printf("Enter an month: ");
    scanf("%d", &m); 
    printf("Enter an day: ");
    scanf("%d", &d);
switch(m){
    case 1:
        printf ("It is Winter!");
        break;
    case(2):
        printf ("It is Winter!");
        break;
    case(3):
        if (d<19){
            printf ("It is Winter!");}
        else{
            printf ("It is Spring!");}
        break;
    case(4):
        printf ("It is Spring!");
        break;
    case(5):
        printf ("It is Spring!");
        break;
    case(6):
        if (d<20){
            printf ("It is Spring!");}
        else{
            printf ("It is Summer!");}
        break;
    case(7):
        printf ("It is Summer!");
        break;
        
    case(8):
        printf ("It is Summer!");
        break;
    case(9):
        if (d<22){
            printf ("It is Summer!");}
        else{
            printf ("It is Fall!");}
        break;
    case(10):
        printf ("It is Fall!");
        break;
    case(11):
        printf; ("It is Fall!");
        break;
    case(12):
        if (d<21){
            printf ("It is Fall!");}
        else{
            printf ("It is Winter!");}
        break;
            
}
}
Output:-




If you need any help in understanding, please comment your query.
I tried my best for this question, I hope you upvote my answer.
Thank You