Hey everyone,

I'm need help with a problem I'm working on. I am trying to write a code that will tell how many coins are in the amount of change from 0 to 99. My algorithm is:
Get total value of change
Set value of quarters to q=.25
Set value of dimes to d=.10
Set value of nickels to n=.05
Set value of pennies to p=.01

If anyone have any suggestions I would greatly appreciate it.

5 Years
Discussion Span
Last Post by Stazloz

Work out how many quarters are in the amount of change.
Display number of quarters.
Subtract (0.25 * number of quarters) from amount of change.
Repeat for dimes.
Repeat for nickels.
Repeat for pennies.


I got that part but one area I'm having a problem is getting it started in the program. See before I can get started I must produce a handwritten sample of the code as if I were on the computer.


Note that although a greedy approach to this problem is optimal, its not a general solution to an optimal solution for all coins. For a general optimal solution, one can use dynamic programming.


I will help you out, you reek of n00bness. But this much just this one time. The first thing you are going to want to do is:

Create 5 variables. One for the cents to be input, and one for quarters, dimes, nickels, pennies.
Ask for the amount of cents.
Determine how many quarters are in that many cents.
Determine how many dimes are in that many cents.
Determine how many nickels are in that many cents.
The amount of pennies are how much is "left"
output how many quarters, dimes, nickels and pennies are in that amount of cents

What I think that they were trying to point out to you is that math is important. You should know what to do to figure out how many quarters are in, say, 50 cents.

This is more than I should provide you, but this should get you in the right direction of what you should know before future posts. Pseudocode is indeed a whole college course of its own, so you are not alone. As for the oh so helpful people who posted above me, way to inspire.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.