(Solved) : Im Trouble Figuring Write Statement Count Vowels Text File M Also Trouble Filling Method F Q44167438 . . .
//Im having trouble figuring out how to write an if statement tocount all of the vowels in the text file and I’m also havingtrouble filling out the method to find duplicate words in thefile.
/* Project2.java */
import java.io.*;
import java.util.*;
public class Project2
{
static final int INITIAL_CAPACITY = 10;
public static void main (String[] args) throwsException
{
// ALWAYS TEST FIRST TO VERIFY USERPUT REQUIRED INPUT FILE NAME ON THE COMMAND LINE
if (args.length < 1 )
{
System.out.println(“nusage: C:> java Project2 <inputfilename>nn”); // i.e. C:> java Project2dictionary.txt
System.exit(0);
}
String[] words = newString[INITIAL_CAPACITY];
int wordCount = 0;
int vowelCount = 0;
BufferedReader infile = newBufferedReader( new FileReader(args[0]) );
while ( infile.ready() )
{
String word =infile.readLine();
// # # # # #DO NOT WRITE/MODIFY ANYTHING ABOVE THIS LINE # # # # #
/*
if wordsarray is full
{
upsize the array
System.out.println( “words.length after upSize:” + words.length ); // use this line
}
now appendthe word onto the end of the array and increment wordCount
now examineevery char in the word and every time you detect an a e i o or u,increment vowelCount
*/
// # # # # # DONOT WRITE/MODIFY BELOW THIS LINE IN MAIN # # # # #
} //END WHILE INFILE READY
infile.close();
words = downSize( words,wordCount );
System.out.println( “AfterdownSize() words.length=” + words.length + “nwordCount=” +wordCount + “nvowelCount=” + vowelCount );
System.out.println( “Theduplicate word is: ” + findFirstDupe( words, wordCount ) );
} // END main
// RETURN AN ARRAY OF STRING 2X AS BIG AS ONE YOUPASSED IN
// BE SURE TO COPY ALL THE OLD OWRDS OVER TO THE NEWARRAY FIRST
static String[] upSize( String[] fullArr )
{
return null;
}
static String[] downSize( String[] arr, int count)
{
return null;
}
static String findFirstDupe( String[] array, intcount )
{
// write a pair of nested loopsthat compare every stinrg to every other string
// as soon as you fond two that are.equals to each other, immediately return that string
return “NO DUPE FOUND IN ARRAY”;// LEAVE THIS HERE
}
} // END CLASS PROJECT#2
Expert Answer
Answer to //Im having trouble figuring out how to write an if statement to count all of the vowels in the text file and I’m also h…
OR