This is my java code import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class WordleWizard { public static
Question:
This is my java code:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class WordleWizard {
public static void main(String[] args) throws FileNotFoundException {
Scanner input = new Scanner(System.in);
System.out.print("Please enter the name of your Wordle file: ");
String filename = input.nextLine();
File file = new File(filename);
Scanner in = new Scanner(file);}
System.out.print("/n");
int count = 0;
while (in.hasNextInt()) {
String line = in.nextLine();
if (line.length() == 5) {
System.out.println(line);
count++;
}
}
System.out.println("/n" + filename + " contained " + count + " valid Wordle words.");
}
}
Description: You will build a program that will ask the user to supply a list of words via a text file (they will provide the file name), and from that list, the program will print out only those words that are five letters long, to help narrow down to only valid Wordle words. You will have no idea how many words are in the file.
Required Skills and Outcomes:
To finish assignment, you will need to:
● obtain user input to get the file name
● loop through a file of unknown length to read words
● determine appropriately long words and print only the selected words to the console
Directions:
1. You first need to get the filename from the user; we've done this before so you should be familiar with the process.
2. Read through the file, one word at a time. You will not know how many words are in the file, but must be careful to read every word and not try to read beyond the end of the file.
3. For each word, if it is a valid Wordle word (for our purposes, this means it is 5 letters long, no need to worry about the actual validity), print it to the screen. If a word is not valid, simply ignore it.
4. At the end, you should report the number of words in the file that were valid. (Hint: keep track of this as you go).
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang