Total price program
I've been trying to code a program that takes in user input to input it into an arraylist. I'm not sure what is going on here or why there are errors.
23 Replies
⌛
This post has been reserved for your question.
Hey @rainymc_! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
The size of
itemNames
is 0.the value "i" is set to 0
this is the error code
Which is caused by?
according to it on line 13 which is "itemNames.add(inpt.next());" the scanner method is undefined
but I've defined my scanner object
Which is totally correct code.
So what's the problem here?
I don't know, the code on the screenshot wouldn't throw any compilation error, although it's noop.
You probably should add something to itemPrices?
Yes that’s for afterwards but as of right now I’m only trying to find a solution to my itemNames issue
When I entered all your code there are no issues. I don't have such an exception.
But I edited your code so it would work and let you enter items and prices.
Well I’m trying to have it so the user will input an answer and the answer will be placed into an array list which I will print later
I’m not sure if inpt.next is the right statement for such a thing
Then you have to think throught your stop condition.
I have it so if the user says stop the loop will break
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
Please format your code to make it more readable. For java, it should look like this:
Alright I’ll try it in a bit
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
Please format your code to make it more readable. For java, it should look like this:
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.