Quick actions

cmd+k|ctrl+k

Navigation

Languages

marketer_capoeirista's problem

Snippet info

Language

Java

Visibility

public

Author

nishtahir

Created

2016-06-21T14:33:32Z

Updated

2016-06-21T14:49:29Z

// BlueJ Project: lesson4/book7
// Video: Working with the Book Text

import java.util.Scanner;
import java.io.File;

public class Main
{
    private int occurences;
    
    public static void main(String[] args)
    {
        System.out.print("Type a word and I'll tell you how many times it appears: ");
        
        // TODO: Create an scanner object to read the user input
        // Read a word from the scanner and assign it to a String variable named word
        Scanner userInput = new Scanner(System.in);
        String word = userInput.nextLine();

        // TODO: Create a book object that reads from aliceInWonderland.txt
        Book alice = new Book("aliceInWonderland.txt");

        // TODO: Find the number of occurences of that word and assign it to a variable named occurences
        int occurrences = alice.occurrencesOf(word);
    }
}
INFO