/*
Write a program to
display the name of
the month of the
accepted month number
from command-line
argument.
*/
class p422
{ public static String monthName(int month)
{ String str=new String();
switch(month)
{ case 1 : str="January"; break;
case 2 : str="February"; break;
case 3 : str="March"; break;
case 4 : str="April"; break;
case 5 : str="May"; break;
case 6 : str="June"; break;
case 7 : str="July"; break;
case 8 : str="August"; break;
case 9 : str="September"; break;
case 10: str="October"; break;
case 11: str="November"; break;
case 12: str="December"; break;
default: str="Wrong Month value";
}
return str;
}
public static void main(String args[])
{ int m=Integer.parseInt(args[0]);
System.out.println(monthName(m));
}
}
Write a program to
display the name of
the month of the
accepted month number
from command-line
argument.
*/
class p422
{ public static String monthName(int month)
{ String str=new String();
switch(month)
{ case 1 : str="January"; break;
case 2 : str="February"; break;
case 3 : str="March"; break;
case 4 : str="April"; break;
case 5 : str="May"; break;
case 6 : str="June"; break;
case 7 : str="July"; break;
case 8 : str="August"; break;
case 9 : str="September"; break;
case 10: str="October"; break;
case 11: str="November"; break;
case 12: str="December"; break;
default: str="Wrong Month value";
}
return str;
}
public static void main(String args[])
{ int m=Integer.parseInt(args[0]);
System.out.println(monthName(m));
}
}
No comments:
Post a Comment