> I need help with Java program please!!?

I need help with Java program please!!?

Posted at: 2014-12-18 
The compiler sees that every assignment of RedHealth is within an if, so it is possible that it will not have a value if none of the conditions are ever true. (What if the user enters a difficulty of 4?)

You should declare the variables at the top and give them initial values.

I cannot firgure out how to correct my code i keep getting the error

GoldVsRed.java:74: variable RedHealth might not have been initialized

int difficulty = input.nextInt();



if (difficulty == 1){

int RedHealth = 50;

int GoldHealth = 75;

}



if (difficulty == 2){

int RedHealth = 50;

int GoldHealth = 50;

}



if (difficulty == 3){

int RedHealth = 75;

int GoldHealth = 50;

}



int RedHealth;

int GoldHealth;



/* Flamethrower = 5;

Rollout = 10;

Swift = 15; */

int goldAttack = input.nextInt();

System.out.println("Choose Your First Move Gold:");

System.out.println("(1) Flamethrower");

System.out.println("(2) Rollout");

System.out.println("(3) Swift");



if (goldAttack == 1){

System.out.println("Typhlosion used Flamethrower!");

System.out.println(RedHealth - 5);

}