write a program to display whether the season is Winter spring summer autumn
Answers
Answered by
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
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...
Answered by
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 () ;
}
#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 () ;
}
Similar questions