I need help with my code when I run my code running the wrong thing like this
After downSize() words.length=60003
wordCount=60003
vowelCount=206728
this is my code here
import java.io.*;
import java.util.*;
public class Project02
{
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("\nusage: C:\\> java Project2 <input
filename>\n\n"); // 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(wordCount==words.length)
{
words = upSize(words);
System.out.println( "words.length after upSize:
" + words.length ); // use this line
}
words[wordCount++] = word; //confused on this
//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
for(int
i=0;i<word.length();i++){
if(word.charAt(i)== 'a'|| word.charAt(i)=='e'||
word.charAt(i)== 'i'|| word.charAt(i)== 'o'||word.charAt(i)
=='u')
{
++vowelCount; //is there a difference between
++vowelCount and 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 + "\nwordCount=" +
wordCount + "\nvowelCount=" + 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 )
{
String[]biggerArr = new String
[fullArr.length*2];
for(int i =0;
i<fullArr.length;i++)
biggerArr[i] = fullArr[i];
return biggerArr;
}
static String[] downSize( String[] arr, int count
)
{
String[]smallerArr = new String
[count];
for(int i=0;i<count;i++)
smallerArr[i]=arr[i];
return
smallerArr;
}
static String findFirstDupe( String[] array, int
count )
{
for(int i = 0;
i<count;i++){
for(int j = i+1;
j<count; ++j){
if(array[i].equals(array[j])){
return array[j];
}
}
}
// 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
FIXED CODE:
INPUT FILE USED:
OUTPUT:

FOR ANY HELP JUST DROP A COMMENT
I need help with my code when I run my code running the wrong thing like...
I need help writing this code for java class. Starter file: Project3.java and input file: dictionary.txt Project#3 is an extension of the concepts and tasks of Lab#3. You will again read the dictionary file and resize the array as needed to store the words. Project#3 will require you to update a frequency counter of word lengths every time a word is read from the dictionary into the wordList. When your program is finished this histogram array will contain the following:...
I need to write a program in java that reads a text file with a list of numbers and sorts them from least to greatest. This is the starter file. import java.util.*; import java.io.*; public class Lab3 { static final int INITIAL_CAPACITY = 5; public static void main( String args[] ) throws Exception { // ALWAYS TEST FOR REQUIRED INPUT FILE NAME ON THE COMMAND LINE if (args.length < 1 ) { System.out.println("\nusage: C:\\> java Lab3 L3input.txt\n"); System.exit(0); } //...
Execute your program like this: C:\> java Lab4 10000ints.txt 172822words.txt Be sure to put the ints filename before the words filename. The starter file will be expecting them in that order. Lab#4's main method is completely written. Do not modify main. Just fill in the methods. Main will load a large arrays of int, and then load a large array of Strings. As usual the read loops for each file will be calling a resize method as needed. Once the...
I need help with my Java code. A user enters a sentence and the program will tell you what words were duplicated and how many times. If the same word is in the sentence twice, but one is capitalized, it will not count it as a duplicate. How can I make the program read the same word as the same word, even if one is capitalized and the other is not? For example, "the" and "The" should be counted as...
need help editing or rewriting java code, I have this program
running that creates random numbers and finds min, max, median ect.
from a group of numbers,array. I need to use a data class and a
constructor to run the code instead of how I have it written right
now. this is an example of what i'm being asked
for.
This is my code:
import java.util.Random;
import java.util.Scanner;
public class RandomArray {
// method to find the minimum number in...
Trying to practice this assignment Argument list: the *yahoonews.txt Data file: yahoonews.txt Write a program named WordCount.java, in this program, implement two static methods as specified below: public static int countWord(Sting word, String str) this method counts the number of occurrence of the word in the String (str) public static int countWord(String word, File file) This method counts the number of occurrence of the word in the file. Ignore case in the word. Possible punctuation and symbals in the file...
I need help running this code. import java.util.*; import java.io.*; public class wordcount2 { public static void main(String[] args) { if (args.length !=1) { System.out.println( "Usage: java wordcount2 fullfilename"); System.exit(1); } String filename = args[0]; // Create a tree map to hold words as key and count as value Map<String, Integer> treeMap = new TreeMap<String, Integer>(); try { @SuppressWarnings("resource") Scanner input = new Scanner(new File(filename));...
hey dear i just need help with update my code i have the hangman program i just want to draw the body of hang man when the player lose every attempt program is going to draw the body of hang man until the player lose all his/her all attempts and hangman be hanged and show in the display you can write the program in java language: this is the code bellow: import java.util.Random; import java.util.Scanner; public class Hangmann { //...
JAVA getting the following errors: Project4.java:93: error: ']' expected arr[index] = newVal; // LEAVE THIS HERE. DO NOT REMOVE ^ Project4.java:93: error: ';' expected arr[index] = newVal; // LEAVE THIS HERE. DO NOT REMOVE ^ Project4.java:93: error: <identifier> expected arr[index] = newVal; // LEAVE THIS HERE. DO NOT REMOVE ^ Project4.java:94: error: illegal start of type return true; ^ Project4.java:98: error: class, interface, or enum expected static int bSearch(int[] a, int count, int key) ^ Project4.java:101: error: class, interface, or...
What is wrong with my code, when I pass in 4 It will not run, without the 4 it will run, but throw and error. I am getting the error required: no arguments found: int reason: actual and formal argument lists differ in length where T is a type-variable: T extends Object declared in class LinkedDropOutStack public class Help { /** * Program entry point for drop-out stack testing. * @param args Argument list. */ public static void main(String[] args)...