1
answer
0
watching
136
views
11 Jun 2018

4. Consider the following program. public class Fraction { private int numerator; private int denominator; public Fraction (int n, int d) { numerator = n; denominator = d; public Fraction add (Fraction f) return new Fraction (numerator * f.denominator + 1. numerator * denominator, denominator + f.denominator); public Fraction add (int x) { return new Fraction (numerator + x denominator, denominator); public Fraction add (int n, int d) return new Fraction (numerator denominator * d); d+n* denominator, public String toString() { return numerator + "/" + denominator; public static void main(String[] args) { Fraction f1 = new Fraction (1, 2); Fraction f2 = new Fraction (2, 3); Fraction f3 = new Fraction (3, 4); Fraction sums = new Fraction [4]; sums [0] - fl.add(f3); sums [1] - f2.add(f3); sums [2] - fl.add(1); sums [31 - f2.add(3, 3); for (int i = 0; i <= sums.length; i++) { System.out.println(sums[i].toString()); The above program compiles without error; what does it display when it is executed?

For unlimited access to Homework Help, a Homework+ subscription is required.

Tod Thiel
Tod ThielLv2
12 Jun 2018

Unlock all answers

Get 1 free homework help answer.
Already have an account? Log in

Related questions

Related Documents

Weekly leaderboard

Start filling in the gaps now
Log in