Hello! I need help with programming. I'm supposed to create a program that will ask you for a year and a month (year: 2011, Month: 1 for January, 2 for February, etc) and it will tell you how many days are in that month (including leapyears). This is what i have so far: import java.util.Scanner; public class Welcome { public static void main(String args[]) { Scanner input = new Scanner(System.in); System.out.print("Enter a year:"); int year = input.nextInt(); System.out.print("Enter a month:"); int month = input.nextInt(); int days = 0; boolean isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); switch (month) { case 1: days = 31; break; case 2: if (isLeapYear) days = 29; else days = 28; break; case 3: days = 31; break; case 4: days = 30; break; case 5: days = 31; break; case 6: days = 30; break; case 7: days = 31; break; case 8: days = 31; break; case 9: days = 30; break; case 10: days = 31; break; case 11: days = 30; break; case 12: days = 31; break; } } }
What language are you writing this program with?
Java I believe, honestly I'm extremely confused with programming.
I think you'll find better help if you post this in the computer science section... this section is only for math related questions.
Had your program needed to solve a mathematical problem, then it would be okay to post in this section. But I do not see that this is the case...
Sorry, I asked this question and it immediately redirected me to make an account, so I'm still trying to figure everything out. Thanks.
No problem, sorry I couldn't help you!
Join our real-time social learning platform and learn together with your friends!