// Read two fractions and perform op import java.util.Scanner; public class TwoFracOp { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Input the 1st fraction: "); String str = input.next(); String[] parts = str.split("/", 2); int n = Integer.parseInt(parts[0]); int d = Integer.parseInt(parts[1]); Fraction frac1 = new Fraction(n, d); System.out.print("Input the 2nd fraction: "); str = input.next(); parts = str.split("/", 2); n = Integer.parseInt(parts[0]); d = Integer.parseInt(parts[1]); Fraction frac2 = new Fraction(n, d); System.out.print("\nWhat op? (+, -, *, /): "); String op = input.next(); Fraction result = new Fraction(); if(op.equals("+")) result = frac1.add(frac2); // out the formula System.out.print("\n\n"); frac1.writeOut(); System.out.print(" " + op + " "); frac2.writeOut(); System.out.print(" = "); result.writeOut(); System.out.print("\n\n"); } }