Skip to content
Advertisement

Tag: input

Java user input, declare as int?

I’m new to Java and I want to make a program that calculates price of donuts by typing in how much donuts you want and then telling you what is the price depending on the number of donuts you want. This is the code What am I missing in my code? I am getting an error in the last line.

How to stop Java Scanner from accepting input

So, I am working on a quiz taking program that works from the command line and the quizzes have time limits. What I want to do, is to stop the quiz right when the user’s time is up even if they’re in the middle of answering a question. I am using Java’s Scanner to get the user’s input, so I

Scanner needs/is requesting input twice

I’m just writing a small program that receives input from the user then prints it back to them. However, when I run the program it asks for input twice (it prints the initial statement, then once you type and press enter, nothing happens, but if you do it again it works and prints.) The top value apparently has no weight

How to take text input with DialogFragment in Android?

I am trying to get a value that user enters into a Dialog, using the recommended DialogFragment class for it, the Dialog constructs and runs fine, but I cannot return the value of the EditText parameter to the parent class, without get a NullPointerException. My DialogHost class, this constructs, returns and links the parent to its buttons. This is my

java.util.NoSuchElementException – Scanner reading user input

I’m new to using Java, but I have some previous experience with C#. The issue I’m having comes with reading user input from console. I’m running into the “java.util.NoSuchElementException” error with this portion of code: I have two functions that get user input: PromptCustomerQty PromptCustomerPayment If I don’t call PromptCustomerQty then I don’t get this error, which leads me to

ArrayList input java

Im looking at the problem: Write a program which reads a sequence of integers and displays them in ascending order. Im creating an ArrayList (which I am new to) and I want to populate with integers input from the command line. With an array I could use a for loop with but with an ArrayList of unbounded size Im not

Closing BufferedReader and System.in

I’ve noticed that if I close the BufferedReader, I won’t be able to insert input from the keyboard anymore, as System.in is somehow closed. Is there anyway I can keep br.close() (I need that in order to delete a file) and then add more input from the keyboard? Answer Looks like you need: http://commons.apache.org/io/apidocs/org/apache/commons/io/input/CloseShieldInputStream.html Wrap that around System.in before making

Advertisement