Quantcast
Viewing all articles
Browse latest Browse all 2

Answer by Jacob B. for Finding the average of certain numbers out of a text file

My first comment is you might want to take some lessons. This is pretty basic stuff.

But to answer your question, use a while loop, with an if/else statement inside, to get proper input.

For your next problem, you probably want to use .nextLine instead of .next, because some file names have spaces in them.

Third problem, use a for loop to check each integer one at a time, and compare it to the range needed. Then use if/if else statements/switch statements and an array to store the values, and after all values are checked, do the math on the content of the array.

Again, i highly recommended taking some basic java lessons.


Viewing all articles
Browse latest Browse all 2

Trending Articles