There are two issues here, which you can consider separately.
- Are you able to describe algorithmically how to determine the answer to your question?
- Given this description, can you turn it into Java code?
I'll start by addressing the first item: It is essential that you understand exactly what the input is and what the required output is and that you are able to give a precise pseudo code description of how to solve the problem. If you don't know what pseudocode is, then look it up on Wikipedia. Then you can start thinking about how to code it in Java.
From an algorithmic perspective, your problem is very simple.
Say the customer pays amount X and for an item that costs amount C.
First you must check that X >= C. otherwise the customer won't have paid enough, and you can stop right there.
Assuming that X >= C, and that you are able to give exact change, the amount of money in the till will have increased by C after the transaction completes, as this exactly what the customer ends up paying.
Now, the amount of change you have to give should equal X-C. Call this Y.
Test how many times the biggest coin you have available divides Y:
Say the biggest coin has value V, then you should give back the customer Y/V coins of this value.
Afterwards, you need to pay back the customer the remaining money Y'=Y-(Y/V)*V. Make sure you know how division works in Java (see link at the end of this post).
Repeat the procedure to pay Y' back using the second biggest coin and so on.
2.
I won't write out the whole thing in Java, but there are some things you should consider.
Does the Till contain "money" without it being specified exactly what bills/coins it contains, or should you be representing the money as a number of bills and coins?
You will be doing integer division, so your coin values should not be doubles but ints.
You need to access the coin values (how much a dime is worth etc.) from inside the function that calculates change, so the values of the different coins should probably be declared as static member variables of the class CoinCalc, not inside a function.
You need to make sure you know how basic if-else statements and while loops work and how to assign to variables. Then you should be able to code the solution.
You also need to decide what exactly the solution is. It could be a list of coin names with a name repeated for each time it is needed, e.g. [dime,penny,penny], or maybe an array of four numbers with that say how many quartes, dimes, nickels and pennies are needed. If you want a list, you should learn how list datastructures work in Java, by reading the entry LinkedList in the Java documentation.
Good luck!
NB: Because I'm a new user, I can't post as many links as I would like. You can find a good description of division in Java by googling java division and selecting the link to mindprod.com.