I am writing a program that reads from a file titled “grades.txt” and displays the student’s name, three grades, and the average of those three grades. The text file looks like this: Here is the code. I am able to read from the file and output everything correctly. However, I keep getting this error and I am not sure why:
Tag: while-loop
Password Checker in java with do while
I need to write a password checker which ensures that password correct. Firstly I prompt the user enter the password Secondly, I prompt the user to reenter the password thirdly, I need to check that the passwords are identical But this steps need to repeat 1 through 3 until password is correctly entered twice. Here is my code. But i
appending arguments to a String
I need to write a simple Java program so as to step through a given string (given from args[]), and receive a println once a certain character (e.g. ‘^’) is encountered. However, I cannot find why I …
Basic Java Hangman
I am just starting to learn Java as my first programming language. In class we were assigned to make a basic Hangman game with the use of a while and for loops. What I have so far When the user inputs the first guess it does recognize that that characters that he/she guessed was corrected but just continues on and
How to exit a while loop after a certain time?
I have a while loop and I want it to exit after some time has elapsed. For example: Answer Thus the statement Checks if it has been 10 seconds or 10,000 milliseconds since the loop started. EDIT As @Julien pointed out, this may fail if your code block inside the while loop takes a lot of time.Thus using ExecutorService would
Break statement inside two while loops
Let’s say I have this: Question: Will the break statement take me out of both loops or only from the inner one? Thank you. Answer In your example break statement will take you out of while(b) loop