Need some help on my HS Project
Code Java:
// import java.text.*;
import java.util.*;
public class charcount
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in);
String line = "";
String ch = "";
int numLetter, numVowel, numDigit, numBlank, numPunct, numOther, numLine, num;
boolean value = true;
System.out.println("Enter \" DONE \" when you are through.");
while (value = true)
{
System.out.print("Enter a Line of text or DONE: ");
line = keyboard.nextLine();
line = line.toUpperCase();
ch.equals(line.charAt(num));
if (line.equals("DONE"))
value = false;
break;
if ((ch >= 'A') && (ch <= 'Z'))
numLetter += 1;
if (ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'Y')
numVowel += 1;
}
}
}
public static void main(String[] args)
{
}
I cannot get this program to run. It seems that I can not use the < or > sign with my variable char. I thought that ch was primitive and I could use those signs but I am very new to this language and I am sure I am doing something wrong. I am trying to get the first letter of a string and find out if it is a letter and a vowel. No rush not due until Friday plus I will ask my instructor tomorrow if no one responds.
Thank You.
Re: Need some help on my HS Project
The method charAt(); returns a char. You are trying to store it in a String variable. So your String ch is not of a compatible type with your charAt() method. You can use those two symbols one you fix your variable type that should right itself. Also get rid of your second main method.