Although the output of following is spring, but how can we use the command line argument for the same program? pls solve thisthanks in advanceclass Ifelse{public static void main(String arr[]){int month=4;String season;if (month==12||month==1||month==2)season = "winter";else if (month==3||month==4||month==5)season = "spring";else if (month==6||month==7||month==8)season = "summer";else if (month==9||month==10||month==11)season = "autumn";elseseason = "bogus month";System.out.println(season);}}

Questions by deepakdev

Showing Answers 1 - 3 of 3 Answers

abhijith

  • Nov 15th, 2006
 

public static void main(String arr[])

{

int month=0;

if(arr[0] != null)

month=Integer.parseInt(arr[0]);

String season;

if (month==12||month==1||month==2)

season = "winter";

else if (month==3||month==4||month==5)

season = "spring";

else if (month==6||month==7||month==8)

season = "summer";

else if (month==9||month==10||month==11)

season = "autumn";

else

season = "bogus month";

System.out.println(season);

}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions