Zebra0.com

alice booleanA True/False Question

A True/False Question

Using if to tell the user the answer is right.

Here is an example of how to ask a True False question in a quiz.



Download this project

public void myFirstMethod() {
    Boolean answer = this.alien.getBooleanFromUser( "The planet Earth has just one moon." );
    if( answer ) {
        this.alien.say( "Yep, just one." );
    } else {
        this.alien.say( "It is true! Can you imagine?? Just one moon!!" );
    }
} 

NEXT: A drill on Boolean values