Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify the readFromDisk method to only output vowels for each line read from a f

ID: 3535808 • Letter: M

Question

Modify the readFromDisk method to only output vowels for each line read from a file.

Example, if a disk has the following text:

hello world!

this is great

testing

The program would print to console only vowels:

eoo

iiea

ei


public static void readFromDisk(String filename) {

System.out.println("Reading from file (" + filename + ") >");

try {

BufferedReader br = new BufferedReader(new FileReader("C:\Users\gmuclass\Downloads\" + filename));

String s;

while((s = br.readLine()) != null) {

System.out.println(s);

}

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

Explanation / Answer

public static void readFromDisk(String filename) {

System.out.println("Reading from file (" + filename + ") >");

try {

BufferedReader br = new BufferedReader(new FileReader("C:\Users\gmuclass\Downloads\" + filename));

String s;

while((s = br.readLine()) != null) {


if(s=='a' || s == 'e' || s== 'i' || s== "o' || s== 'u')

System.out.println(s);

}

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote