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.
No description
23 Replies
JavaBot
JavaBot3mo ago
This post has been reserved for your question.
Hey @rainymc_! Please use /close or the Close 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
szatkus
szatkus3mo ago
The size of itemNames is 0.
rainymc_
rainymc_OP3mo ago
the value "i" is set to 0
rainymc_
rainymc_OP3mo ago
No description
rainymc_
rainymc_OP3mo ago
this is the error code
szatkus
szatkus3mo ago
Which is caused by?
rainymc_
rainymc_OP3mo ago
according to it on line 13 which is "itemNames.add(inpt.next());" the scanner method is undefined but I've defined my scanner object
szatkus
szatkus3mo ago
Which is totally correct code.
rainymc_
rainymc_OP3mo ago
So what's the problem here?
szatkus
szatkus3mo ago
I don't know, the code on the screenshot wouldn't throw any compilation error, although it's noop.
tjoener
tjoener3mo ago
You probably should add something to itemPrices?
rainymc_
rainymc_OP3mo ago
Yes that’s for afterwards but as of right now I’m only trying to find a solution to my itemNames issue
Tomasm21
Tomasm213mo ago
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.
rainymc_
rainymc_OP3mo ago
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
szatkus
szatkus3mo ago
Then you have to think throught your stop condition.
rainymc_
rainymc_OP3mo ago
I have it so if the user says stop the loop will break
JavaBot
JavaBot3mo ago
💤 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
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
JavaBot
JavaBot3mo ago
Please format your code to make it more readable. For java, it should look like this:
​`​`​`​java
public void foo() {

}
​`​`​`​
​`​`​`​java
public void foo() {

}
​`​`​`​
rainymc_
rainymc_OP3mo ago
Alright I’ll try it in a bit
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
JavaBot
JavaBot3mo ago
Please format your code to make it more readable. For java, it should look like this:
​`​`​`​java
public void foo() {

}
​`​`​`​
​`​`​`​java
public void foo() {

}
​`​`​`​
JavaBot
JavaBot3mo ago
💤 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.
Want results from more Discord servers?
Add your server