Here is the code,
System.out.print("Enter r1: ");
r1 = in.next();
System.out.print("Enter r2");
r2 = in.next();
System.out.println(myR.addR(r1,r2));
r1 and r2 is initialize as Rational.
Here is my question,
How can I change r1=in.next (which is in string form)into a rational form? Can I write r1 = in.Rational ....any tips plzzz
This is very easy to solve.
Instead of
r1 = in.next();, user1 = in.nextInt()orr1 = in.nextDouble(), depending on which kind of number you want.