# return method problem

**999594**Apr 8, 2013 2:54 PM

Hello: I am stuck on something I need a bit of guidance on. Here is what I am needing to do:

Write a class encapsulating the concept of coins, assuming that coins have the following attributes: a number of quarters, a number of dimes, a number of nickels, a number of pennies. Include a constructor, the accessors and mutators, and methods toString and equals. Also code the following methods: one returning the total amount of money in dollar notation with two significant digits after the decimal point, and other returning the money in quarters ( for instance, 0.75 if there are three quarters ), in dimes, in nickels and in pennies. Write a client class to test all the methods in your class.

I am stuck on how to structure my total return method. Here is what I have so far, thanks for the help.

Write a class encapsulating the concept of coins, assuming that coins have the following attributes: a number of quarters, a number of dimes, a number of nickels, a number of pennies. Include a constructor, the accessors and mutators, and methods toString and equals. Also code the following methods: one returning the total amount of money in dollar notation with two significant digits after the decimal point, and other returning the money in quarters ( for instance, 0.75 if there are three quarters ), in dimes, in nickels and in pennies. Write a client class to test all the methods in your class.

I am stuck on how to structure my total return method. Here is what I have so far, thanks for the help.

```
import java.text.DecimalFormat;
public class Coins
{
private int quarters;
private int dimes;
private int nickels;
private int pennies;
private int total;
public Coins ()
{
}
public Coins ( int q, int d, int n, int p, int t )
{
quarters = q;
dimes = d;
nickels = d;
pennies = p;
total = t;
}
public int getQuarters()
{
return quarters;
}
public int getDimes()
{
return dimes;
}
public int getNickels()
{
return nickels;
}
public int getPennies()
{
return pennies;
}
public int getTotal()
{
return total;
}
}
```

- 98 Views
- Tags: none (add)