• Post Reply Bookmark Topic Watch Topic
  • New Topic

need help with arrray  RSS feed

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am supposed to output the total (price * amount) for some reason it does not output. I tried using a for loop and that didnt work either

 
Ranch Hand
Posts: 1143
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What behavior are you seeing now?  And what were you seeing when you had the last couple lines in a for loop?
 
Junaid Mahmud
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont understand what you are trying to say
 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junaid Mahmud wrote:I dont understand what you are trying to say


You said that something "doesn't work". This is one of the most unhelpful things you can say if you have a problem. So Ryan (on behalf of all of us) is asking you to clarify that by explaining what outputs, error messages, etc you are seeing.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose the last lines of code you have added is causing the problem.

Try with this in the end.



Hope this helps.
 
Ranch Hand
Posts: 61
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think this should solve the problem....


hope it helps....
 
adebari olalekan
Ranch Hand
Posts: 61
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


or more explicitly.....



 
Sheriff
Posts: 4298
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
adebari olalekan and Rajith Pemabandu:

Thank you for your contribution.  In the Beginning Java we try to lead the OP to the answer and only post our solutions after the OP has posted theirs.
 
Knute Snortum
Sheriff
Posts: 4298
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajith Pemabandu wrote:

The for loop would be better like this:
Also, "l" is a poor choice of variable name, since it looks so close to "1".
[Edit]  Ah, but now I see that you were just using the original program's names.
 
Knute Snortum
Sheriff
Posts: 4298
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
adebari olalekan wrote:i think this should solve the problem....



I agree that Scanner is better than InputStreamReader for getting input from the console.

With Scanner, there's no need to use Integer.parseInt().  Just use sc.nextInt().
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!