Welcome to the section 8 challenge.
For this program, I'm going to be using US dollars and cents,
but feel free to use whatever currency system you're familiar with that you want to use.
The idea here is you want to write a program that asks the user to enter the following.
Ask them to enter an integer representing the number of cents.
You can assume that the number of cents entered is greater than or equal to zero.
The program then displays how to provide that change to the user.
So in the U.S, we have one dollar is a hundred cents, a quarter is 25 cents,
a dime is 10 cents, a nickel is 5 cents, and a penny is one cent.
So in this example suppose the user enters 92 cents.
Your results will display that you can provide this change as follows.
No dollars.
Three quarters that would be 75 cents.
A dime, which would be another 10 cents that would give you 85.
The nickel is 5., there's your 90. And the two pennies, there's your 92.
As I said feel free to use your own currency system.
Also think of how you might want to solve this problem using the modulo operator.
When i give you my solution, I'll have two solutions.
I'll have one without the modulo operator and one that uses the modulo operator,
just so you can see two different ways to approach the problem. Quick hint,
please don't just sit down and start coding this. Think about how you want to solve it.
Write down some pseudocode that's English-like statements so you can get your thoughts straight.
Figure out what your algorithm is or your steps that you want to use to solve the program.
So have fun, make sure you test your program. Don't forget to test zero.
Don't forget to test large numbers.
And what I'm going to do is I'm going to do a couple of sample runs just so you can see how this works.
So in this example it says enter an amount in cents.
So let's say I type in 92 cents.
And the program responds you can provide change for this as follows.
Dollar zero, three quarters, one dime,
one nickel, two pennies, just like we would expect.
As I mentioned don't forget to test with zero,
and we should get all zeros straight down the line.
And let's say we want to test
this with 267 cents, that's 2 dollars and 67 cents.
In this case, we've got our two dollars, we've got two quarters. That gives us 50,
the dime gives us 60,
the nickel 65 and the two pennies 67.
So there are your 267 cents. All right. So
have a go at it.
And when you come back, go to the solutions section. I'll go over my solution.
Good luck.