1
oi its broken
DanielBrammer33 (0)

cheers fix it please cos im trash coder need help 5$ paypal to whoever helps cheers x x x x x x x x x x x x

You are viewing a single comment. View All
Answered by mwilki7 (111) [earned 5 cycles]
View Answer
3
mwilki7 (111)

I could be wrong, it's been a while since I've programmed in Java but:
Main.java
The thingy that runs your code is looking for a class called "Main"
Try renaming:

class projectpractice
{
    ....
}

To

class Main
{
    ...
}
2
mwilki7 (111)

I have added 2 new lines to your code here:
https://repl.it/@mwilki7/Project

Your logic was correct, the only thing you tripped on was Java syntax. (which can be annoying sometimes)

First one is:

    File file = new File("Users.txt");
    Scanner inputfile = new Scanner(file);

It looks like your program is reading from an existing file, instead of a new one, so I used the File class to open it, and scanner reads from it.

The second change:

for(int index = 0; index <= 6 && inputfile.hasNext(); index ++ )

I added a condition: index < 6 && inputfile.hasNext();
makes sure you don't read too much (past the end of the file).

To help you catch errors better I changed the second catch statement

    catch (Exeption ex)
        {
            System.out.println("Something else has gone wrong.");
        }   

since it's hard to tell which error was caught if the error code reports the same thing.