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

Write a program that reads a file a character at a time and prints out how many

ID: 3759746 • Letter: W

Question

Write a program that reads a file a character at a time and prints out how many times the vowels a e i o u occur (in upper- or lowercase).

Complete the following file:

Vowels.java

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

public class Vowels
{
public static void main(String[] args) throws FileNotFoundException
{
String vowels = "aeiou";
int[] counters = new int[vowels.length()];

Scanner console = new Scanner(System.in);
System.out.print("Input file: ");
String inputFileName = console.next();

. . .

for (int i = 0; i < vowels.length(); i++)
{
System.out.println(vowels.charAt(i) + ": " + counters[i]);
}
}
}

Explanation / Answer

Vowels.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Vowels
{
public static void main(String[] args) throws FileNotFoundException
{
String vowels = "aeiou";
int[] counters = new int[vowels.length()];
Scanner console = new Scanner(System.in);
System.out.print("Input file: ");
String inputFileName = console.next();
. . .
for (int i = 0; i < vowels.length(); i++)
{
System.out.println(vowels.charAt(i) + ": " + counters[i]);
}
}
}

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