0
what am i doing wrong ?
//Prints true if the given m = month and d = day fall between // March 20 (inclusive) and June 20 (inclusive) public class IsaSpringDay { public static void main(String[]args) { int m = Integer.parseInt(args[0]); int d = Integer.parseInt(args[1]); if (m >= 3 && m <= 6 && d <= 20){ System.out.println("True"); } else { System.out.println("False");}
3 Respostas
+ 1
hey,
Your code is absolutely right but.you forgot to complete main method and class so } } add this 2 brackets to your code.
If you want to run your code online refer following site:
Pass Command line argument (day and Month) and Check output
https://www.jdoodle.com/online-java-compiler/
0
but what if the month is 5 and the day is 21 my code wouldn't include it when it should.
0
Swith case better works here.. Cases for months Or go if else..
If month ==3,then date must not less than 20 if month ==6 then date shloud not greater than 20.. Else only check month is between 3 and 6 or not..
Or java has time and with limitations with date classes, learn about those....