Cash Register

QG_Omega
US Enlisted: 2012-01-11
2012-05-10 20:07
Anybody every wondered how a cash register exactly calculates how much money to give back to you? Here's an example: the cashier has to give back 248 cents to the customer in change...what's the most efficient way? Here's the code (in Java):

import static java.lang.System.out;

class CashRegister {
public static void main(String args){
int total = 248;
int quarters = total/25;
int whatsleft = total % 25;

int dimes = whatsleft/10;
whatsleft = whatsleft % 10;

int nickels = whatsleft / 5;
whatsleft = whatsleft % 5;

int cents = whatsleft;

out.println("From " + total + " cents you get:");
out.println(quarters + " quarters");
out.println(dimes + " dimes");
out.println(nickels + " nickels");
out.println(cents + " cents");
}
}
McIngles
AQ Enlisted: 2011-10-25
2012-05-10 20:10
Sweet.
acid270
MT Enlisted: 2011-11-10
2012-05-10 20:25
Cool.

---------------------------------------------------------------------------------------------------
http://s09.flagcounter.com/count/ANx/bg_FFFFFF/txt_000000/border_000000/columns_8/maxflags_40/viewers_0/labels_0/pageviews_0/flags_1/ [s09.flagcounter.com]
Cryotoad
GI Enlisted: 2011-11-04
2012-05-10 20:26
I had to write this exact code about five weeks ago.
Where were you then?!?!?
Lol, Jk. I take it you are taking a programming course?
"Oops" can be one of the more terrifying words you'll ever hear. If you hear me say it, it's probably the last word you'll ever hear. Henceforth, I wish that everyone refer to circles as "Omnihedrons" That is all.
ZeaIo7isBoo
US Enlisted: 2012-02-23
2012-05-10 20:33
thank you??
QG_Omega
US Enlisted: 2012-01-11
2012-05-11 00:08
Cryotoad said:
I had to write this exact code about five weeks ago.
Where were you then?!?!?
Lol, Jk. I take it you are taking a programming course?

Not taking a programming class. Actually, I already have my masters degree in meteorology but I'm learning Java, Python and C++ on my own. I just thought it was interesting when I figured it out.
Cryotoad
GI Enlisted: 2011-11-04
2012-05-11 14:02
Cool. Personally, I prefer Python, it just seems more intuitive and fluid than JAVA. I've yet to try my hand at any variation of C though.
"Oops" can be one of the more terrifying words you'll ever hear. If you hear me say it, it's probably the last word you'll ever hear. Henceforth, I wish that everyone refer to circles as "Omnihedrons" That is all.
OoGeneralryanoO
PH Enlisted: 2011-10-27
2012-05-11 14:18 , edited 2012-05-11 14:43 by OoGeneralryanoO
Hey I am a programmer maybe I can help you out. But I'm not really familiar with Java (I only know few things but I'm currently studying java) I know C, C++, Visual basic.

But i have a question. What's "total=248" for?
To get the change of a certain purchase. You need to subtract the amount tendered from the total amount of purchases

Example:
change=amt_tendered-total

Like for example. I need to pay $3.42 (this will be the total amount of purchases). So I gave $5.50 as my payment (This will be your amount tendered) so my change is $2.08

I have a C program on basic cash register. If you want I can give you the source code. But I used Borland Turbo C for that.

----------------------------------------------
http://www.youtube.com/watch?v=yUox-F3eXr0 [youtube.com]
HAHAHA!!! I LAUGH AT THE TITLE AND THE NEWSCASTER LOL
PEW PEW PEW PEW BOOM
Marticus100
GB Enlisted: 2011-11-22
2012-05-11 14:20
thanks OP i can fap tonight guilt free and safe in the knowlege that there is a peice of javacode out there that calculates what's in a cash register.

it's giving me a boner just thinking about it

you must get all the pussy
QG_Omega
US Enlisted: 2012-01-11
2012-05-11 21:46
Marticus100 said:
thanks OP i can fap tonight guilt free and safe in the knowlege that there is a peice of javacode out there that calculates what's in a cash register.

it's giving me a boner just thinking about it

you must get all the pussy

^^^Troll