Question
//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 having
//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 having trouble filling out the method to find duplicate words in the file.
/* Project2.java */
import java.io.*; import java.util.*;
public class Project2 { static final int INITIAL_CAPACITY = 10; public static void main (String[] args) throws Exception { // ALWAYS TEST FIRST TO VERIFY USER PUT REQUIRED INPUT FILE NAME ON THE COMMAND LINE if (args.length < 1 ) { System.out.println(" usage: C:\\> java Project2 "); // i.e. C:\> java Project2 dictionary.txt System.exit(0); }
String[] words = new String[INITIAL_CAPACITY]; int wordCount = 0; int vowelCount = 0;
BufferedReader infile = new BufferedReader( new FileReader(args[0]) ); while ( infile.ready() ) { String word = infile.readLine();
// # # # # # DO NOT WRITE/MODIFY ANYTHING ABOVE THIS LINE # # # # #
/*
if words array is full { upsize the array System.out.println( "words.length after upSize: " + words.length ); // use this line }
now append the word onto the end of the array and increment wordCount
now examine every char in the word and every time you detect an a e i o or u, increment vowelCount
*/
// # # # # # DO NOT WRITE/MODIFY BELOW THIS LINE IN MAIN # # # # #
} //END WHILE INFILE READY infile.close();
words = downSize( words, wordCount ); System.out.println( "After downSize() words.length=" + words.length + " wordCount=" + wordCount + " vowelCount=" + vowelCount );
System.out.println( "The duplicate word is: " + findFirstDupe( words, wordCount ) );
} // END main
// RETURN AN ARRAY OF STRING 2X AS BIG AS ONE YOU PASSED IN // BE SURE TO COPY ALL THE OLD OWRDS OVER TO THE NEW ARRAY FIRST static String[] upSize( String[] fullArr ) { return null; }
static String[] downSize( String[] arr, int count ) { return null; }
static String findFirstDupe( String[] array, int count ) { // write a pair of nested loops that 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started