Question
Please explain/comment this code import java.util.*; public class month { int monthinput() { Scanner s=new Scanner(System.in); return(s.nextInt()); } String monthname(int n) { String a; if(n==1)
Please explain/comment this code
import java.util.*; public class month {
int monthinput() { Scanner s=new Scanner(System.in); return(s.nextInt()); } String monthname(int n) { String a; if(n==1) { return ("january"); } if(n==2) { return("febrauary"); } if(n==3) { return("march"); } if(n==4) { return("april"); } if(n==5) { return("may"); } if(n==6) { return("june"); } if(n==7) { return("july"); } if(n==8) { return("august"); } if(n==9) { return("september"); } if(n==10) { return("october"); } if(n==11) { return("november"); } if(n==12) { return("december"); } return null; } void displaymonth(String ss) { System.out.println("the given month is"+" "+ss); } }
driver programme is
public class driver {
public static void main(String args[]) { month m=new month(); int x=m.monthinput(); String s=m.monthname(x); m.displaymonth(s); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started