import java.util.Scanner; public class String2Bool { public static boolean parseBoolean( String s ) { /* ------------------------------------------------------- Signal to students that we are using our own method ! ------------------------------------------------------- */ System.out.println("*** You called BooleanIO's parseBoolean( )"); if ( s.equals("true") ) return true; else return false; } public static void main(String[] args) { Scanner in = new Scanner( System.in ); String input; boolean x; System.out.print("Enter a boolean value: "); input = in.nextLine(); x = parseBoolean(input); // Convert string repr to Boolean // *** Try replacing this method call // *** with Java's Boolean.parseBoolean() if ( x ) { System.out.println("You have entered the `true' boolean value"); } else { System.out.println("You have entered the `false' boolean value"); } } }