Hey guys I've been having trouble with my code within the if statements. Regardless of what I enter the if statements always return f_resist [] to 0. I think there is an error along my if statements but im not sure :(
Scanner u_scancolor = new Scanner(System.in); //declare input box
System.out.println("Enter three colors on the resistor seperated by hyphens. ie: Red-Blue-Brown");
System.out.println("Colours you can use: Black, Brown, Red, White, Orange, Yellow, Green, Grey, Violet, Blue");
String f_wire = u_scancolor.next(); //takes a string
System.out.println(f_wire);
int [] f_resist;
f_resist = new int [3];
String [] f_wordcolor= f_wire.split("-"); //splits the colors by hyphen into individual strings
for (int cnt1=0 ; cnt1<3; cnt1++) {
f_wordcolor [cnt1] = f_wordcolor [cnt1].toUpperCase();
System.out.println(f_wordcolor [cnt1]);
if (f_wordcolor [cnt1] == "BLACK ") {
f_resist [cnt1] = 0;
}
else if (f_wordcolor [cnt1] == "BROWN") {
f_resist [cnt1] = 1;
}
else if (f_wordcolor [cnt1] == "RED") {
f_resist [cnt1] = 2;
}
else if (f_wordcolor [cnt1] == "ORANGE") {
f_resist [cnt1] = 3;
}
else if (f_wordcolor [cnt1] == "YELLOW") {
f_resist [cnt1] = 4;
}
else if (f_wordcolor [cnt1] == "GREEN") {
f_resist [cnt1] = 5;
}
else if (f_wordcolor [cnt1] == "BLUE") {
f_resist [cnt1] = 6;
}
else if (f_wordcolor [cnt1] == "VIOLET") {
f_resist [cnt1] = 7;
}
else if (f_wordcolor [cnt1] == "GREY") {
f_resist [cnt1] = 8;
}
else if (f_wordcolor [cnt1] == "WHITE") {
f_resist [cnt1] = 9;
}
System.out.println(f_resist [cnt1]);
}
String f_add1 = Integer.toString(f_resist [0]);
String f_add2 = Integer.toString(f_resist [1]);
String f_stringadd = f_add1 + f_add2;
int f_intadd = Integer.parseInt(f_stringadd);
int f_ohm = f_intadd*10^f_resist[2];
System.out.println("Total ohms: " + f_ohm);
}
}