fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println(daysInMonth(2,2016));
  13. }
  14. public static int daysInMonth(int m, int y) {
  15. int d;
  16. if (m == 1 || m == 3 || m == 5 || m == 7
  17. || m == 8 || m == 10 || m == 12) {
  18. d = 31;
  19. } else if (m == 4 || m == 6 || m == 9 || m == 11) {
  20. d = 30;
  21. } else if (y % 4 == 0 && m == 2) {
  22. d = 29;
  23. } else if (m == 2) {
  24. d = 28;
  25. } else {
  26. d = 0;
  27. }
  28. return d;
  29. }
  30. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
29