I have two classes.
import java.util.Scanner;
public class Fraction
{
private int numerator;
private int denominator;
public void inputValues()
{
Scanner kb = new Scanner(System.in);
System.out.println("Enter your numerator: ");
numerator = kb.nextInt();
System.out.println("Enter your denominator: ");
denominator = kb.nextInt();
}
public int getNumerator() //GetMethod
{return numerator;}
public boolean isZero()
{
if (getNumerator ==0)
return false;
}
}
I want my program to stop looping once the value for numerator is 0. and I've made a silly mistake somewhere but I cant seem to see it or figure out why. Many thanks in advance and much appreciated.
public class FractionDemo{
public static void main (String[]argv) {
Fraction f1 = new Fraction();
Fraction f2 = new Fraction();
f1.inputValues();
f2.inputValues();
while(f1.isZero())
{
f1.inputValues();
f2.inputValues();
}
}
}
Fraction?