Assignemnt #30: Comparing Strings

Code

 /// Name: Sean Harrison
    /// Period: 7
    /// Program name: Comparing Strings
    /// File Name: WeaselOrNot.java
    /// Date Finished: 10/2/2015
    
import java.util.Scanner;

public class WeaselOrNot
{
    public static void main( String[] args )
    {
        Scanner keyboard = new Scanner(System.in);
        
        String word;
        boolean yep, nope;
        
        System.out.println( "Type the word \"Weasel\" , please." );
        word = keyboard.next();
        
        yep  =   "weasel".equals(word);
        nope = ! word.equals("weasel");
        
        System.out.println( "You typed what was requested : " + yep );
        System.out.println( "you ignored polite instructions: " + nope );
        
    }
}

    /// When the syntax of "Weasel" and word are flopped on line 15, the code does compiles, and the output is identical to beforehand.                      
    


 

Picture of the output

Assignment 30