✅ Working on a change calculator, need help
So far this is what i got but i dont know what to do from here. these are the steps required
Step 1: Prompt the user to enter the cost of the item
Step 2: Prompt the user to enter the amount paid
Step 3: Calculate the change
Step 4: Determine the number of each type of coin needed for the change
Step 5: Display the number of each type of coin to give as change
its just step 4,5 im having trouble with, also if you notice any errors or anything i could fix let me know
22 Replies
how would you do it if you were making change in real life?
What do you mean
this might sound stupid but id legit just use a calculator
you need to subtract the double by the highest currency value (starting from $1 [1.0], down to $0.01 [.01])
could you convert this in AUD
or is that dragged
whats AUD
australian dollar
what exactly would you need to change...?
i dont know this nickels dimes system
actually
i think i can do it
other than taht
thank you alot gah damn
goat
also
int oneDollars = 0;
while (change >= 1)
{
change -= 1;
oneDollars++;
what excatly does this bit do?
while the change amount is greater than or equal to 1.0, take $1 away from change and increment the dollar amount by one
so:
dollars = 0
change = 43.32
after one loop, it becomes:
dollars = 1
change = 42.32
the same for all other amounts
so:
twentyCents = 0
change = 13.60
after one loop becomes:
twentyCents = .20
change = 13.40
ohhhhh i see
thank you
yw
$close
Use the /close command to mark a forum thread as answered
@mzxsu I know you closed it, but I honestly wouldn't use any kind of loop for that if I were you.
(And take that as a lesson of "Because something works doesn't mean it's the right solution.")
he didnt close it
and i just did it for simplicity's sake
if you got something else, please share
Yes, he did.
that was me, telling how how to close it
Oh. Well I'm wrong! Sorry
But before I'll elaborate on how, I'll see if they're still around.
its okay
any word starting with '
$
' is a command for info
and you can tell if the thread is closed because the title will have a ✅ in front of itoh i see
ok got it
$close
Use the /close command to mark a forum thread as answered