Hey everyone so I made this basic code for assignment and I am just lost, the code is really more of any outline but im hoping someone can help me edit it and format it correctly
so in this code he wants us to make code that will allow user to enter month and year and display how many days are in that month. In this chapter is the code for how to determine a leap year. Use that as part of your code to make this program work correctly Ex: user enters month 2 and year 2012. The program needs to display February 2012 had 29 days
Input dialog boxes and output command window
so can anyone look over this and tell me what I need to change or help me re format it please or even make it shorter or is there an easier way to make a code like this
PLEASE HELP
public static void main(String[] args) { Scanner input = new Scanner (System.in); int MonthNum; int Year; int numDays; String Month; System.out.print("Please enter the Month #"); MonthNum = input.nextInt(); System.out.print("Please enter the Year"); Year = input.nextInt(); if (MonthNum == 2) { if ( (Year % 4 == 0) && (Year % 400 == 0) && !(Year % 100 == 0) ) numDays = 29; else numDays = 28; } else if (MonthNum == 1 || MonthNum == 3 || MonthNum == 5 || MonthNum == 7 || MonthNum == 8 || MonthNum == 10 || MonthNum == 12) numDays = 31; else numDays = 30; if (MonthNum == 1) Month = "January"; else if (MonthNum == 2) Month = "Feburary"; else if (MonthNum == 3) Month = "March"; else if (MonthNum == 4) Month = "April"; else if (MonthNum == 5) Month = "May"; else if (MonthNum == 6) Month = "June"; else if (MonthNum == 7) Month = "July"; else if (MonthNum == 8) Month = "August"; else if (MonthNum == 9) Month = "September"; else if (MonthNum == 10) Month = "October"; else if (MonthNum == 11) Month = "November"; else if (MonthNum == 12) Month = "December"; System.out.println(Month + " " + Year " has " + numDays "." ); System.out.println(Month); System.out.println(numDays); } }