text to sql syntaxMon, 27 Mar 2023

Write a program to build a class PhanSo that has 2 properties, numerator and denominator. The program has getter and setter methods for properties and has the following functions: - reduce(): minimize fractions - inverse(): inverse fraction - add(PhanSo p2): add 2 fractions - subtract(PhanSo p2): subtract 2 fractions - multiple(PhanSo p2): multiply 2 fractions - divide(PhanSo p2): divide 2 fractions - compare(PhanSo p2): compare 2 fractions. Returns 0 if 2 fractions are equal, 1 if 1st fraction is greater and -1 if 1st fraction is less

public class PhanSo { private float tuSo; private float mauSo; public PhanSo() { this.tuSo = 0; this.mauSo = 1; } public PhanSo(float tuSo, float mauSo) { this.tuSo = tuSo; this.mauSo = mauSo; } public float getTuSo() { return tuSo; } public void setTuSo(float tuSo) { this.tuSo = tuSo; } public float getMauSo() { return mauSo; } public void setMauSo(float mauSo) { this.mauSo = mauSo; } public PhanSo congPS(PhanSo phanSo2) { PhanSo phanSo = new PhanSo(); phanSo.tuSo = this.tuSo * phanSo2.mauSo + phan

Questions about programming?Chat with your personal AI assistant