Below is some code for a self checkout machine. My runningtotal variable is not adding up all the numbers the user inputs. It's only outputting the most recent user input. Any help would be appreciated
Shaktar Donetsk wrote:Below is some code for a self checkout machine. My runningtotal variable is not adding up all the numbers the user inputs. It's only outputting the most recent user input. Any help would be appreciated
Suggest you to go through Java(TM) Operators and find out about the error. Its pretty straight forward.
Shaktar Donetsk
Greenhorn
Joined: Nov 27, 2012
Posts: 7
posted
0
Well I'm only a beginner. Is there a simple way and if so could you briefly explain it? Thanks
EDIT: This is only for a small assignment. My question is, how do I make it so runningtotal outputs the total instead of the price.
Here's a picture, it says the total is the inputted number when it should be an addition of all the prices that came before it.
Shaktar Donetsk wrote:Oh. Well then how would I go about adding a users input with their previous one. Like a running total of their inputs?
Well, since you have been doing this for hours, what have you tried so far?
Henry
Shaktar Donetsk
Greenhorn
Joined: Nov 27, 2012
Posts: 7
posted
0
I created a topic on another site. I've only tried the for loop and a lot of other smaller things like moving the location of 'double runningtot' because it wasn't declared locally or something along those lines. Just tinkering with things but no clear answer.
Shaktar Donetsk
Greenhorn
Joined: Nov 27, 2012
Posts: 7
posted
0
Any suggestions or fixes would be greatly appreciated.
Shaktar Donetsk wrote:I created a topic on another site. I've only tried the for loop and a lot of other smaller things like moving the location of 'double runningtot' because it wasn't declared locally or something along those lines. Just tinkering with things but no clear answer.
Yeah, "tinkering with things" with no clear direction is not very efficient. You should have at least have an idea of what you are tinkering with. I recommend taking a look at the Oracle tutorial, here is the pages for the operations and expressions.
I've got a project due soon though. I knew how to do it before but its slipped my mind. I know it's something very simple, can you show me?
Praveen Kumar M K
Ranch Hand
Joined: Jul 03, 2011
Posts: 256
posted
0
Shaktar Donetsk wrote:I've got a project due soon though. I knew how to do it before but its slipped my mind. I know it's something very simple, can you show me?
That wouldn't help you understand anything and after some time you will again face the same problem. Atleast go through the operator list through Henry's link and see whether there indeed is an operator like =+
Shaktar Donetsk wrote:I've got a project due soon though.
That's really not relevant to us. We're happy to help, but if you make it URGENT or stressful, folks will just walk away and not bother.
Shaktar Donetsk wrote: I knew how to do it before but its slipped my mind. I know it's something very simple, can you show me?
The link Henry provided tells you what valid operators are. look at it CAREFULLY, and see if you can find "=+" (or perhaps something that looks a lot like it).
Never ascribe to malice that which can be adequately explained by stupidity.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.