I'm trying to make a program that will make string s1 equal to certain text depending on the hours variable. The problem is when I run the program s1 isn't found. I'm just starting out with Java so I'm not sure if this is really inefficient or if it's something simple I'm missing.
Code:
public class Main {
public static void main(String[] args) {
// String Change Test
int[] arr;
arr = new int[2];
arr[0] = 1;
boolean b1 = arr[0] > 1;
boolean b2 = arr[0] < 1;
boolean b4 = 0 > arr[0];
boolean b3 = b4 && b2;
boolean b5 = b1 || b3;
if (b5) {
String s1 = "You have played for " + arr[0] + " hours!";
}
else if (arr[0] == 1) {
String s1 = "You have played for 1 hour!";
}
else if (arr[0] == 5) {
String s1 = "You have not played at all!";
}
else {
String s1 = "Memory Error in arr[0], Are the hours negative? Is it there?";
}
System.out.print (s1);
}
}