sandy skiathitis wrote:ok so I have started doing my code and it ran perfectly. I needed to do a menu for a restaurant in which it took the customers order and then calculated their total price. Well, now I want to be able to calculate the number of items sold from all the customers up to the last order! also I want the owner to have a total money count. Is this possible? Please help I am stuck!
Oracle Java SE6 Certified Programmer
Oracle Java EE5 Certified Web Component Developer
Pivotal Certified Spring Professional
Certified ScrumMaster
If debugging is the process of removing bugs, then programming must be the process of putting them in. -- Edsger Dijkstra
jishnu dasgupta wrote:Please use code tags!!
sandy skiathitis wrote:
jishnu dasgupta wrote:Please use code tags!!
i dont know how to!
luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:
sandy skiathitis wrote:
jishnu dasgupta wrote:Please use code tags!!
i dont know how to!
https://coderanch.com/how-to/java/UseCodeTags
But I know how to and I have added the tags, and removed some empty lines. Don't let it worry you.sandy skiathitis wrote:
Darryl Burke wrote:
sandy skiathitis wrote:
jishnu dasgupta wrote:Please use code tags!!
i dont know how to!
https://coderanch.com/how-to/java/UseCodeTags
i think i ruined it!! omg I suck at this !!!Im sooooo sorry!
Campbell Ritchie wrote:
But I know how to and I have added the tags, and removed some empty lines. Don't let it worry you.sandy skiathitis wrote:
Darryl Burke wrote:
sandy skiathitis wrote:
jishnu dasgupta wrote:Please use code tags!!
i dont know how to!
https://coderanch.com/how-to/java/UseCodeTags
i think i ruined it!! omg I suck at this !!!Im sooooo sorry!
You ought to provide correct indentation, however, using 4 spaces at a time, not tab characters.
Nico Van Belle wrote:Everything is possible (well...olmost everything )
But without the proper information we can't help you.
Like .. What info do you store in your database?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie wrote:Well done
But how did you get it to work?
fred rosenberger wrote:I added code tags to your post (which is why you'll see me as the 'last edited by').
To put them in, when you make or edit your post, just highlight all your source code, then click the 'code' button above where you enter your text. You'll see them pop in just before and after what you highlight. They preserve your formatting and make it easier to read.
I think your code has a few issues...
this line:
is almost without a doubt wrong. When you put that semi-colon there, you'll get either get stuck in an infinite loop, or code will run you don't think should.
This code:
looks like it will also give you an infinite loop. when you come in to the numberOfInstances() method, you set numItems to 0. you enter your while statement, and since numItems is NOT equal to -1, you add 1 to frequency. but numItems is STILL not equal to -1, so you add another 1 to frequency... etc.
The best way to approach writing code is to break down your problem first. Forget about Java, or C, or Pascal, or whatever language you are coding in. Think about it in English (or whatever your native language is).
Let's think about what we'd need to do to get totals for ALL customers. I would probably need something that remembers everything done. In the real world, I'd have a register audit tape that records every transaction.
Maybe what I need here is something that stores transactions.
OK...so what should be in a transaction? Do I need to know WHAT they ordered, or just how many total things they ordered and the total price? We can work towards either approach, but how we go forward depends on the answer.
If debugging is the process of removing bugs, then programming must be the process of putting them in. -- Edsger Dijkstra
It's still a mistake, and he must have missed the ; when you showed him it.sandy skiathitis wrote: . . .
my professor said that was great and to keep it in my code
So did I. Did we do it simultaneously? Is that why it looked so peculiar when I tried it?fred rosenberger wrote:I added code tags to your post (which is why you'll see me as the 'last edited by'). . . ..
Wanna see my flashlight? How about this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|