I'm learning Java and I have this program that tells the sign depending on the day and month the user writes. The program works as it is, but if the user enters a day like 90 or so, the program doesnt evaluate that "error". Can I correct this with a try/catch? If so, how do I write it? Here's the code (a piece of it), thanks in advance
import java.util.Scanner;
public class Signo{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int day, month;
System.out.println("Day Input:");
day=in.nextInt();
System.out.println("Month Input:");
month=in.nextInt();
int result=getSign(day,month);
}
private static int getSign(int day, int month){
switch(month){
case 1:
if(month==1 && day>=20){
System.out.println("Your sign is Aquarius");
}else{
System.out.println("Your sign is Capricorn");
}
break;
//etc
}
return day;
}
}