I want to get a rational number from the user in the form 188/4 for example and end up with int 188 and int 4. what is an efficient way to do this in java? is stringTokenizer the best way?? or is there something like scanf in c??
private int NUM;
private int DEN;
static Scanner s;
public Rational(){
s = new Scanner(System.in).useDelimiter("/");
System.out.println("Enter Rational number in the form of a/b:");
NUM = s.nextInt();
int d = s.nextInt();
if(d == 0){
throw new IllegalArgumentException();
}
else{
DEN = d;
}
}
when I run this my program freezes after I input a number