Question: In Java Please Part 1 : ( Implemented for you ) Pass in the name of the file as input. For example we ll have
In Java Please
Part : Implemented for you
Pass in the name of the file as input.
For example well have input Filetxt
From there read the content of the File one word at a time using a while loop.
Create a tally called countInt, countFloat, countWord, and countSymbol.
Part :
Implement Method :
Public static boolean isTokenIntString token
This method takes a String and determines if its content is an integer
Here is how an integer is defined
Optional or followed by one or more digits
In grammar form
integer sign digit
sign
digit number number digit
number
Go through the String token one character at a time and see if it meets the requirement above
Return true if its an integer
Return false otherwise
Implement Method :
Public static boolean isTokenFloatString token
This method takes a String and determines if its content is a float
Here is how a float is defined
Optional or followed by zero or more digits
Followed by followed by one or more digits
In grammar form
float signdigitdigit
sign
digit number number digit
number
Go through the String token one character at a time to see if it meets the requirements above.
Return true if its a float
Return false otherwise
Implement Method :
Public static boolean isTokenWordString token
This method takes a String and determines if its content is a word
Here is how a word is defined
one or more letters AZaz
Go through the string token one character at a time to see if it meets the requirements above.
Return true if its a string
Return false otherwise
Part :
If method returns true increase countInt by If method returns true increase countFloat by if method returns true increase countWord by otherwise increase countSymbol by
Part : Implemented for you
At the end of the while loop print out the following
The file is filename
Filename contains countInteger integers
Filename contains countFloat floats
Filename contains countWord words
Filename contains countSymbol symbols
Part : OPTIONAL FOR EXTRA POINTS
Enhance Method :
Public static boolean isTokenWordString token
This method takes a String token and determines if its content is a word
Use the following to determine if its a word accounting for grammar symbols
one or more letters AZaz followed by optional : ;
Go through the string token one character at a time to see if it meets the requirements above.
Return true if its a string
Return false otherwise
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
