Advertisement
IanO-B

Untitled

Mar 10th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. public class Main {
  2.  
  3. public static void main( String[] args )
  4. {
  5. System.out.println( "Month 1: " + month_name(1) );
  6. System.out.println( "Month 2: " + month_name(2) );
  7. System.out.println( "Month 3: " + month_name(3) );
  8. System.out.println( "Month 4: " + month_name(4) );
  9. System.out.println( "Month 5: " + month_name(5) );
  10. System.out.println( "Month 6: " + month_name(6) );
  11. System.out.println( "Month 7: " + month_name(7) );
  12. System.out.println( "Month 8: " + month_name(8) );
  13. System.out.println( "Month 9: " + month_name(9) );
  14. System.out.println( "Month 10: " + month_name(10) );
  15. System.out.println( "Month 11: " + month_name(11) );
  16. System.out.println( "Month 12: " + month_name(12) );
  17. System.out.println( "Month 43: " + month_name(43) );
  18. }
  19.  
  20. public static String month_name(int month)
  21. {
  22. String result = " ";
  23.  
  24. if(month==1){
  25. result="January";
  26. }else if(month==2){
  27. result="February";
  28. }else if(month==3){
  29. result="March";
  30. }else if(month==4){
  31. result="April";
  32. }else if(month==5){
  33. result="May";
  34. }else if(month==6){
  35. result="June";
  36. }else if(month==7){
  37. result="July";
  38. }else if(month==8){
  39. result="August";
  40. }else if(month==9){
  41. result="September";
  42. }else if(month==10){
  43. result="October";
  44. }else if(month==11){
  45. result="November";
  46. }else if(month==12){
  47. result="December";
  48. }else if(month>=13){
  49. result="error";
  50. }
  51. return result;
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement