Assignemnt #30: Comparing Strings

Code

    /// Name: Kelsey Lieberman
    /// Period 5
    /// Program Name: ComparingStrings
    /// File Name: ComparingStrings.java
    /// Date Finished: 10/7/2015
    
import java.util.Scanner;

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

    

Picture of the output

Assignment 30