Hey All Newbie here, I have a project due in a couple days for school that I need a little help with.
The project is to take a user inputed string and print out how many Characters,Digits,Vowels,whitespace and letters are in the string. I was able to get the string and character length ok, but I need to create Used defined method for all the other parts.
Here is my code so far the problem I am having is the method that I am trying to develop for whitespace counts. I keep compiling a "Illegal start of expression" fault. Can any one simply point me in the right direction please?
This is an intro course so I can not use Regular expression yet.
Thanks
import java.util.*;
public class p6
{
static Scanner kb = new Scanner(System.in);
public static void main(String [] args)
{
String x; // declared string variables
System.out.print("Enter a string for character classification: (EOF to end): ");
while (kb.hasNext())//while loop needed to run EOF
{
x = kb.nextLine();// Reads input
System.out.println("The inputLine is " + x.length() + " characters long and contains the following:.");
System.out.print("Enter a string for character classification: (EOF to end): ");}
// Method for counting white space
public int whiteSpace(){
int whiteSpaceCount=0;
for(int i=0;i<s.length();i++)
{
if (x.charAt(i) ==' ');
whiteSpaceCount++;
}
}
}
}
_________________
If at first I don't succeed I'ma try it again and when I do accomplish it I'ma try it again"-Lil Wayne