First of all, you need an opening brace after your class declaration to indicate where the body of your class starts:
public class Main
{
You cannot use the this pointer in a static method, such as the main();
Your last function has only a body, but no signature to it. Give it a return value, a name, and a parameter list. E.g.:
public void PrintEligibility()
{
int num = 18;
if (num % 2 == 0)
{
System.out.println ("you are qualified to vote");
}
else
{
System.out.println ("you are not qualified to vote");
}
}
Next thing to do is instantiating the class and calling your functions on it so your program actually does something as right now (if the invalid statements are removed from the main()) it does nothing.
Your code refactored, fixed and some logic changed to better match real life would look like this:
User.java
public class User
{
private String _name;
private String _password;
public User(String name, String password)
{
_name = name;
_password = password;
}
public String GetName() { return _name; }
public void SetName(String name) { _name = name; }
public String GetPassword() { return _password; }
public void SetPassword(String password) { _password = password; }
public boolean CanVote(int age) { return age >= 18; }
}
Main.java
import java.util.Scanner;
public class Main
{
public static void main (String[] args)
{
User user = new User("Thomas Tester", "Easy password");
if (user.CanVote(18))
System.out.println("You are qualified to vote.");
else
System.out.println("You are not qualified to vote.");
}
}