I have a Java code that checks input from the keyboard. There is a loop of if that for specific character returns True. The else returns false for any other character.
How to write a code that identifies which of the above two (True or False) was chosen by the program and print it? The boolean value of the instance connectionStatus
import java.util.Scanner;
public class BlueTooth3 {
public boolean connectionStatus;
boolean connectBlueTooth () {
System.out.println("Enter connecting code Baby3");
Scanner keyboard = new Scanner(System.in);
String conCode = keyboard.next();
System.out.println("You Entered " + conCode);
keyboard.close();
if (conCode.equals ("c")){
System.out.println(conCode + " Is a true Code");
System.out.println("This is Boolean " +Boolean.TRUE);
return connectionStatus;
}
if (conCode.equals ("C")){
System.out.println(conCode + " Is a true Code");
System.out.println("This is Boolean " +Boolean.TRUE);
return connectionStatus;
}
else {
System.out.println( conCode + " Is a false Code" );
System.out.println("This is Boolean " + Boolean.FALSE);
return connectionStatus;
}
}
}