Computer Science, asked by ruchi396, 1 year ago

write a program to display whether the season is Winter spring summer autumn

Answers

Answered by MacTavish343
2
Hell.. ooo!!

class Switch {

    public static void main(String args[]) {

        int month = 4;

        String season;

        switch (month) {

          case 12:

          case 1:

          case 2:

            season = "Winter";

            break;

          case 3:

          case 4:

          case 5:

            season = "Spring";

            break;

          case 6:

          case 7:

          case 8:

            season = "Summer";

            break;

          case 9:

          case 10:

          case 11:

            season = "Autumn";

            break;

          default:

            season = "Bogus Month";

        }

        System.out.println("April is in the " + season + ".");

    }

}


hope this helps you

ruchi396: thanks a lot,it helped me in school...
MacTavish343: welcome
Answered by Anonymous
1
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
clrscr();

int month ;
switch(month)
                      {
                       case '12':cout<<"This is winter "\n;
                       break;
                       case '1':cout<<"This is winter "\n;
                       break;
                       case '2':cout<<"This is winter "\n;
                       break;
                       case '3':cout<<"This is spring "\n;
                       break;
                       case '4':cout<<"This is spring "\n;
                       break;
                       case '5':cout<<"This is spring "\n;
                       break;
                       case '6':cout<<"This is summer "\n;
                       break;
                       case '7':cout<<"This is summer "\n;
                       break;
                       case '8':cout<<"This is summer "\n;
                       break;
                       case '9':cout<<"This is  Autumn "\n;
                       break;
                       case '10':cout<<"This is  Autumn "\n;
                       break;
                       case '11':cout<<"This is  Autumn "\n;
                       default : cout<<"Invalid option ... Please try again \n";
                       }
getch () ;
}

ruchi396: thanks for ur response
Similar questions