This question is answered on Chegg here ->http://www.chegg.com/homework-help/bui
ID: 3551390 • Letter: T
Question
This question is answered on Chegg here ->http://www.chegg.com/homework-help/building-java-programs-a-back-to-basics-approach-2nd-edition-chapter-7-problem-17e-solution-9780136091813, but I need help figuring out these additional instructions. Which are...
1. You are to call the method vowelCount from main(), where you declare only, i.e. no
initialization, a 1-dimensional, int array reference that will receive the reference
RETurned by method vowelCount, to the 5 element array that it creates that contains
the counts of lower-case vowels found in a text disk file.
2. Your method is to accept one argument, a File object, by reference of course, which
is bound to a file name and RETurn a reference to a 1-dimensional array.
3. In main(), you are to solicit the file name from the User and verify that the file can be
opened for reading before the method vowelCount is called; you are to issue an error
message if the file cannot be opened for reading.
4. If the file can be opened, call the vowelCount method, then display the array
contents in the following format:
a e i o u
--- --- --- --- ---
23 49 26 45 25
5. As the text problem states, you are to count only lower-case vowels in the file. The
values shown in the display example above represent the vowel counts for the
supplied text file, vowelText.txt, which you can use to test your program.
Explanation / Answer
Explanation:
1. The method vowelCount takes the reference to file as argument and return a reference to a one dimension array.so, we are only declaring one dimensional array in main and not initializing it as our declared array will refer to the reference given by vowelCount method. This clarifies point 1 and 2.
2. It then reads that file and count number of vowels of each type.
3. Since the method is taking input file as argument so, we must check if that file exists and if we can read that file or not. If we can not read the input file, then we need to throw an error. This clarifies your point 3.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.