// Illustrates operations with fractions and underflow (a=1,b=100000001,c=1,d=100000002) import java.util.Scanner; class Fraction { public static void main (String[] args) { String div; int a, b, c, d; Scanner scan = new Scanner(System.in); System.out.print("Type a rational number (a / b): "); a = scan.nextInt(); div = scan.next("/"); b = scan.nextInt(); System.out.print("Type a another rational number (c / d): "); c = scan.nextInt(); div = scan.next("/"); d = scan.nextInt(); System.out.println(" " + a); System.out.println("--- = " + a/(float)b); System.out.println(" " + b); System.out.println(" " + c); System.out.println("--- = " + c/(float)d); System.out.println(" " + d); System.out.println("The fractions are equal: " + (a*d==b*c)); System.out.println("The decimals are equal: " + (a/(float)b==c/(float)d)); } }