This is my code so far below
这是我目前的代码
import java.util.*;
import java.io.*;
public class USconstitution
{
public static void main(String [] args) throws Exception
{
Scanner inFile = new Scanner(new File("constitution.txt"));
int x = 0;
int keyword1 = 0;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter a word from the keyboard");
String input = keyboard.next();
while(inFile.hasNext())
{
String word = inFile.next();
x++;
if(input.equalsIgnoreCase(word))
keyword1++;
}
//System.out.println("\n" + x);
System.out.println("The constitution has " + x + " words");
System.out.println("The first keyword shows up " + keyword1 + " times in the
constitution");
}
}
impor