So the gist of this program is to create a Rational class so that when you run it, a GUI input will come up and ask for a numerator and a denominator. It will then return the reduced fraction. But I keep getting this error message and I don't know why. Here's the program so far:
import javax.swing.JOptionPane;
public class lab8
{
public static void main (String args[])
{
String strNbr1 = JOptionPane.showInputDialog("Enter Numerator ");
String strNbr2 = JOptionPane.showInputDialog("Enter Denominator ");
int num = Integer.parseInt(strNbr1);
int den = Integer.parseInt(strNbr2);
Rational r = new Rational(num,den);
JOptionPane.showMessageDialog(null,r.getNum()+"/"+r.getDen()+" equals "+r.getDecimal());
System.exit(0);
}
}
class Rational
{
private int num;
private int den;
public Rational()
{
num = 0;
den = 1;
}
public double getNum()
{
return num;
}
public int getDen()
{
return den;
}
}