class coincollection { private int quarters = 0; private int dimes = 0; private int nickels = 0; // accessor functions: public int getq() { return quarters; } public int getd() { return dimes; } public int getn() { return nickels; } public void addquarters(int amt) { quarters = quarters + amt; } public double dollarworth() { double answer; int totalcents; totalcents = quarters*25 + dimes*10 + nickels*5; answer = totalcents / 100.0; return answer; } public boolean worthmore(coincollection x) { boolean answer; if (this.dollarworth() > x.dollarworth()) answer = true; else answer = false; return answer; } } // coincollection public class ncoins { public static void main(String[] args) { coincollection mycoins; coincollection yourcoins; mycoins = new coincollection(); yourcoins = new coincollection(); mycoins.addquarters(5); yourcoins.addquarters(7); if (mycoins.worthmore(yourcoins) ) System.out.println("I have more money"); else System.out.println("You have more money"); } }