Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I intend to let the user choose what they want to filter by choosing 1-5. If the user chooses 1, the program should ask them to enter the year they want to filter, after that, it should check the length of the input, if it is equal to 4 then it should check whether the text file contains a line that matches the input. But if the user enters 2019, which is equal to 4 digit, the record and the no such records will display at the same time.What if i only want the No such record to be disply only the year enter by the user have no record in the text file?
[textfile][1]
This is the part of the code which causes the behavior you do not like:
if(line.contains(input))
{
System.out.println(input);
System.out.println(input);
}
Change it to
if(line.contains(input))
{
System.out.println(line);
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am fairly new to Java programming and have been using a for loop in my program. I noticed whenever my program asks for user input, that whenever I press the enter key that is used as the next key for the second iteration of the loop. Is there a way to make this not occur?
Use while loop instead:
while(true){
String input = JOptionPane.showInputDialog(null, "Please enter something.");//take inputs while have not encountered STOP
if(input.equals("STOP")){
System.exit(0);
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
If someone tries to login for 5 times the otp should expire when the user tries it for the 6th time.
Any suggestions will be appreciated.
Increase the counter for each incorrect code entry and when it reaches 6 show an error
Without any further information what your OTP system is or anything, all we can do are educated guesses.
First, I have to guess what your actual problem is, because the answer is too obvious.
You have a counter (saved whereever the OTP is saved), and for each bad attempt you add 1. When it reaches 6, you delete the OTP from the database/service/whatever, and show the user a warning that you have done so. Then you reset the counter to 0 (for the new password).
Upon successfully entering the password, you also reset the counter.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
So I am creating a program that need to create as many strings and integers as the user says. The amount is stored in wordlength, and I need to create these strings programmatically based on the input. Can somebody help me?
First, ask the user to input how many strings to store. This can be done through a Scanner.
Then, make an array of type String with length equal to the user input number.
Then, fill in the array through a Scanner with a for loop.
I hope next time you search about you problem before you write a question about it.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to implement a functionality in java where I can search by both by username or by employee number within a single search bar.
I am looking for a simple solution either at client side or at java side
Thanks in advance
Just perform the first search, if it gives a result use it. If not then do the second search.
If usernames must contain alphabetic characters and employee numbers cannot contain them then you could look at the contents of the string and decide which search to run based on that.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to use an EditText in my android app which enables users to enter 8 bit numbers into the column. Which need to be stored in the database and would retrieve the 8 bit number when asked to display?.I am unable to figure out how to do that. Help me with this.Thank you
Octal is base-8 number system.
You can use numbers ranging from 0 - 7.
int octal = 01 acts as an Octal number, the prefix 0 indicates octal.
You can make your EditText show only numeric keyboard and before saving it in the database check if the entry contains 8 or 9 display a message as "Not a decimal number" else save it in your database and while displaying append a 0 in the beginning and show it on your UI.