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

given yahoonews.txt Should the San Francisco 49ers unexpectedly release quarterb

ID: 3871729 • Letter: G

Question

given

yahoonews.txt

Should the San Francisco 49ers unexpectedly release quarterback Colin Kaepernick in a final round of roster cuts on Saturday, he might have an interesting barrier to his next NFL job: ownership.

Citing the controversial and highly visible nature of Kaepernics national anthem protest, four highly ranked executives from the four clubs said even discussing Kaepernick as an option in the future would require ownership signoff in their respective franchises.

However youre looking at it, [signing or trading for Kaepernick] is an endorsement of how the situation has been handled, one executive said. ?I have to explain to [my team owner] that a guy is going to [protest] the national anthem and draw attention to himself over the rest of the team. But I?ve got to say, Heres why we want to attach our franchise to this. ? Its not happening without him being OK with it.

Explanation / Answer

Please see below code which calculates No is Words present on files. this file exclude any words formed by a special charctors. for ex. '?', '*?' will not be considered as word.

Code:

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

public class WordCount

{

public static void main(String args[])

{

System.out.println("count is: "+coutWords());

}

private static int coutWords()

{

String FileName="yahoonews.txt";

int count=0;

BufferedReader br = null;

FileReader fr = null;

try

{

fr = new FileReader(FileName);

br = new BufferedReader(fr);

String sCurrentLine;

while ((sCurrentLine = br.readLine()) != null)

{

count=count+countWordInLine(sCurrentLine);

}

}

catch(IOException er)

{

er.printStackTrace();

}

return count;

}

private static int countWordInLine(String sCurrentLine)

{

int count=0;

String[] wordArray= sCurrentLine.split(" ");

for(int i=0;i<wordArray.length;i++)

{

if(isValidWord((wordArray[i])))

{

count++;

}

}

return count;

}

private static boolean isValidWord(String string)

{

if(string.contains(",") || string.contains("?") || string.contains("!") || string.contains(".") || string.contains(":")

|| string.contains("$") || string.contains("&") || string.contains("#"))

{

for(int j=0;j<string.length();j++)

{

if(isAlphabet(string.charAt(j)))

{

return true;

}

}

}

else

{

return true;

}

return false;

}

private static boolean isAlphabet(char charAt)

{

int charector=(int)charAt;

if((charector>=65 && charector<=90) || (charector>=97 && charector<=122))

{

return true;

}

return false;

}

}

Output:

count is: 145

Thanks