Write a program that reads data from the text file a05 part1.txt. The txt file must be downloaded from this dropbox along with assignment. Read one character at a time from this file and count the number of vowels in the file. There is no input to be read from the user. But, you must output the number of vowels to the user. Your program must follow all style guidelines.

Respuesta :

Answer:

// Program is written in Java Programming Language

// Comments are used for explanatory purpose

import java.io.*;

public class countVowels

{

public static void main(String[] args) throws IOException

{

File file = new File("part1.txt");

FileInputStream fileStream = new FileInputStream(file);

InputStreamReader input = new InputStreamReader(fileStream);

BufferedReader reader = new BufferedReader(input);

String line;

// Initializing counters

int count = 0;

// Reading line by line from the file until a null is returned

while((line = reader.readLine()) != null)

{ // Check if line is not empty

if(!(line.equals(" ")))

{

characterCount += line.length();

char [] ch = new char[characterCount];

for(int I = 0; I<characterCount; I++)

{

if (str.charAt(i) = 'a' || str.charAt(i) = 'e' || str.charAt(i) = 'i' || str.charAt(i) = 'o' || str.charAt(i) = 'u' || str.charAt(i) = 'A' || str.charAt(i) = 'E' || str.charAt(i) = 'I' || str.charAt(i) = 'O' || str.charAt(i) = 'U')

{

count++;

}

}

}

}

System.out.print("Total Vowels = "+count);

}

}