Assignment #30: Comparing Strings

Code

/// Name: Kiran O'Farrell
/// Period: 7
/// Program name: Comparing Strings
/// File Name: ComparingStrings.java
/// Date Finished: 9/2/15

import java.util.Scanner;

public class ComparingStrings {
    
    public static void main (String[] args) {
        
        Scanner keyboard = new Scanner(System.in);
        
        String word;
        
        Boolean yes, no;
        
        System.out.print("Please type the word \"weasel\". ");
        word = keyboard.next();
        
        yes = word.equals("weasel");
        no = ! word.equals("weasel");
        
        System.out.println("You typed the right word: " + yes);
        System.out.println("You did not follow the instructions: " + no);
            
    }
        
}
    

Picture of the output

Assignment 30