First things first. You need to have hitPoints()
method outside the main. You can't nest it inside the main()
method.
And also, the return type of your hitPoints()
is void, you have return statements in the method. Change the return type to int
, so that you can return an int
value from this method to the calling method.
public static int hitPoints(){
Also, since its a do-while
loop(exit check loop), you don't need the default return. Instead initialize your hitPoints
to 0
by default.
public static int hitPoints() { // return type is int, to return an int value
int hitPoints = 0; // default value
do {
Scanner input = new Scanner(System.in);
System.out.println("What is the hit points for the fighter");
hitPoints = input.nextInt();
return hitPoints;
} while (hitPoints <= 50);
// return 0; // not required, as its a do-while loop above
}