generate functionMon, 12 Dec 2022

Write a method for the fraction class which has two integer attributes (num, denom) that adds this fraction with the fraction passed to the method and returns the sum of the two fractions.

public Fraction add(Fraction other){ int num = this.num*other.denom + this.denom*other.num; int denom = this.denom * other.denom; return new Fraction(num, denom); }

Questions about programming?Chat with your personal AI assistant