Forums Register Login

calculate the cost of shopping

+Pie Number of slices to send: Send
hi guys ;
As a new beginner in Java ... i want yr help :

the owner of shop is having trouble with his staff
giving the wrong change. he wants to designa program that allows the staff member to enter the total cost of the shopping
and the amount the customer has paid. The program should then calculate and
output how many euro50, euro20, euro10, euro5 notes, and how many e2, and e1 coins
to give the customer as change.
the owner refuses to deal with small coins so although the staff member
enters a decimal value for the cost of the shopping he rounds all of his prices
down to the nearest euro and doesn’t bother with 50c, 20c, 10c, 5c, 2c or 1c
coins.
Thanks
+Pie Number of slices to send: Send
Marcus lewis,

Welcome to Code Ranch.

It seems to be a homework to me. If it is please DoYourOwnHomework

Please understand that code ranch is NotACodeMill. You will have to ShowSomeEffort first.

Tell us what you have tried and what is the error that occurs. We will help you to solve those errors. We can't give away codes as per code ranch's policy.
+Pie Number of slices to send: Send
it is not a homework first.
second. i did the scanner class. let the code gets the totalCost and amountPaid.

but i dont know how to let the program differentiate between notes and coins and says your change for example 50 euro note and 2 euro coins ....
i could do it in the way just say yr change 52 euro ...
just know am learning java 5 days ago ... that is why i need forums ...
+Pie Number of slices to send: Send
Welcome again

Right: so you have got the amount paid and the amount of the bill. I presume you can work out the amount of change easily now? Why are your Eurozone traders so curmudgeonly as only to charge to the nearest whole number? Once you have the program it is easier to calculate change to the nearest cent than to try rounding.
I would suggest you learn about enumerated types which you can read about in the Java™ Tutorials. You can use an enum to create a object corresponding to each denomination of money and you can even add a value and N or C to that object.

By the way: please search this forum. Change is a common beginner's assignment and you will probably find other discussions which will be helpful.
+Pie Number of slices to send: Send
Also, this is crossposted here.

While we don't mind if you cross post to another site, we do ask that you cite where you have done so. You can read up on why we prefer it this way here -> BeForthrightWhenCrossPostingToOtherSites
+Pie Number of slices to send: Send
thanks cambell ... this is what i need ... enum ... thanksssss
+Pie Number of slices to send: Send
You're welcome

By the way: you will find calculating change much easier if you denominate everything in whole numbers rather than floating‑point numbers. Use ints and caount in cents.
+Pie Number of slices to send: Send
I merged your stuff with the following thread. I hope that is okay by you.
+Pie Number of slices to send: Send
guyes kindly any one who amend this code to be the following

instead of USD let it be Euro :

in the receipt it has to say 50 or 20 or 10 or 5 euro bills and 2 or 1 coins ( no need for the cents in the change)

if there is cents in change the program has to near it down to the nearst value .. ex : if change 32.40 it has to take it just 32euro and says 30 euro bills and 2 coins.

no need for the rest like record.

please help me!!!
+Pie Number of slices to send: Send
Marcus,

I've moved your post to this new topic.
Please show some effort and show us what you have come up with so far.
+Pie Number of slices to send: Send
 

Marcus lewis wrote:instead of USD let it be Euro :


Actually, that's kind of irrelevant.

Both currencies are divided into 100 cents, so whatever solution you come up with for Euros should work equally well for Dollars, Rubles, or Yuan..

But Karthik is right: TellTheDetails (←click) and show us what you've tried already.

Winston
+Pie Number of slices to send: Send
There is something familiar about this question. I am sure I have already given you advice. I have told you to stick to integer arithmetic and denominate everything in whole numbers either € or ¢ or $ or something. You will find it much easier not to have to do rounding. Beware of floating‑point arithmetic; things will go horribly wrong if you enter $12.34 and find it is interpreted as twelve dollars and 33.99999999999999999999 cents.

You should not ask the same question twice. Nil desperandum; I can join this question to your old thread.
How do they get the deer to cross at the signs? Or to read this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1427 times.
Similar Threads
Help with breaking change into bills and coins.
Homework Problem with int and %
quadruple
program statements second
program
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:29:58.