Suppose i want to assign the variable named involved the value true if another variable, say the variable named p, has a value between 50 and 150. How do i do this?
I've tried the following:
import java.util.Scanner;
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int p = scan.nextInt();
boolean involved;
if (p >= 50 && p <= 150) {
involved = true;
System.out.println(included);
}
}
However when i try this i get upp the error: variable p might not been initialized. What am i doing wrong?
Aucun commentaire:
Enregistrer un commentaire