
help me a bit tough
Code:
public class BetterProgrammerTask {
public static Change getCorrectChange(int cents) {
/*
[COLOR="Black"][B][U] Please implement this method to
take cents as a parameter
and return an equal amount in dollars and coins using the minimum number of
coins possible.
For example: 164 cents = 1 dollar, 2 quarters, 1 dime and 4 cents.
Return null if the parameter is negative.[/U][/B][/COLOR]
*/
}
// Please do not change this class
static class Change {
private final int _dollars;
private final int _quarters; //25 cents
private final int _dimes; // 10 cents
private final int _nickels; // 5 cents
private final int _cents; // 1 cent
public Change(int dollars, int quarters, int dimes, int nickels, int cents) {
_dollars = dollars;
_quarters = quarters;
_dimes = dimes;
_nickels = nickels;
_cents = cents;
}
public int getDollars() {
return _dollars;
}
public int getQuarters() {
return _quarters;
}
public int getDimes() {
return _dimes;
}
public int getNickels() {
return _nickels;
}
public int getCents() {
return _cents;
}
}
}

pavankumar: please show some effort.

Please use the code tags also, next time when you are posting code. Unformated codes are really hard to read. If you don't know how to do it, please check on my signature as well as on Fubarables' signature. You can relevant on FAQ as well. :)
And also please ask your question more clearly. I'm not clear what you are really want to know here. Please use an appropriate title next time.
pavankumar2215, I'm not trying to discourage you to ask questions here. But those small things make a big difference on your way. Honestly I want to help you, with your commitment. Good luck :)

Monetary units are designed such that if you use your largest coin as much as possible you have reduced your problem unless there is 0 left and you have solved your problem; the solution is the least amount of coins needed to make the amount of money you started with.
A coin system that doesn't have this propery is, e.g., 1, 7, 12; you can make 28 by using 4x7; if you follow the rule described above you'd end up with 2x12+4x1 which isn't optimal.
The 1, 2, 5 system (e.g. US dollars) needs less coins than, say, the old Dutch guilder system which was 1, 2 1/2, 5.
Anyway, use the rule I outlined above to solve your problem and take the cent as your monetary unit.
kind regards,
Jos