Results 1 to 9 of 9
- 08-17-2011, 06:02 AM #1
Member
- Join Date
- Aug 2011
- Posts
- 5
- Rep Power
- 0
how to determine if uppercase vowel or consonant, lowercase vowel or consonant, etc
hi to all.. i'm a newbie to this environment.. kindly help me with the code..
i have to print if the inputted character is uppercase vowel or consonant, lowercase vowel or consonant, a number or a special character..
here's the code..
kindly check my code if it is correct or if there's any error..Java Code:import java.util.Scanner; class VowelConsonant { public static void main(String[] args) { char character ; String characterinput ; Scanner scan = new Scanner(System.in); boolean vowel = false; System.out.print("Enter an alphabet letter (A through Z : "); char letter = scan.nextLine().charAt(0); switch(letter) { case 'A': case 'E': case 'I': case 'O': case 'U': vowel = true; break; default: vowel = false; break; } if (vowel) { System.out.println(letter + " is a Vowel."); } else if(letter >= 'A' && letter <= 'Z') { System.out.println(letter + " is a Uppercase.") } else if (letter >= 'a' && letter <= 'z') { System.out.println(letter + "is a Lowercase.") } else (vowel) { System.out.println(letter + " is a Consonant"); }
thanks in advance..
Last edited by mariahfrancheszca; 08-17-2011 at 06:05 AM.
- 08-17-2011, 06:56 AM #2
Your compiler will do that for you. If you have a specific question about a specific error, post it here, with the full text of the error and indicating the line of code responsible.kindly check my code if it is correct or if there's any error.
db
- 08-17-2011, 07:09 AM #3
Member
- Join Date
- Aug 2011
- Posts
- 5
- Rep Power
- 0
how to determine..
actually sir, i don't have any error.. but when i run this code, i guess it has an error..
how to attacched image first?. thanks
- 08-17-2011, 07:11 AM #4
Do not attach images.
Copy and paste the full and exact error message. If you are using the command prompt then click on the icon in the top left hand corner to bring up an edit menu.
- 08-17-2011, 07:13 AM #5
Member
- Join Date
- Aug 2011
- Posts
- 5
- Rep Power
- 0
thanks.. here's the print out after i run the code..
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See Java SE Documentation at a Glance for more details.
Press any key to continue . . .
thanks..
- 08-17-2011, 07:24 AM #6
For starters the code you posted will not compile so I have no idea how you are running it.
Secondly the output you see is telling you how to run the java command as you have not invoked it correctly.
Java Code:// to compile javac MyClass.java // to run java MyClass
- 08-17-2011, 08:52 AM #7
Member
- Join Date
- Aug 2011
- Posts
- 5
- Rep Power
- 0
i revised my code and now, its running..
but, one more question, how to determine the uppercase and lowercase of both vowels and consonants?.
CODES:
thanks.. do i need to add some statements or methods?. can you help me with this?. thanks a lot..Java Code:import java.util.Scanner; class Chuvaness { public static void main(String[] args) { char character ; String characterinput ; Scanner scan = new Scanner(System.in); boolean vowel = false; System.out.print("Enter an alphabet letter (A through Z : "); char letter = scan.nextLine().charAt(0); switch(letter) { case 'A': case 'E': case 'I': case 'O': case 'U': vowel = true; break; default: vowel = false; break; } if (vowel) { System.out.println(letter + " is a vowel."); } else System.out.println(letter + " is a consonant"); } }
- 08-17-2011, 09:20 AM #8
Member
- Join Date
- Aug 2011
- Posts
- 5
- Rep Power
- 0
i need your help.. please. thanks..
- 08-17-2011, 11:15 AM #9
Senior Member
- Join Date
- Nov 2010
- Posts
- 210
- Rep Power
- 3
Similar Threads
-
vowel couting
By aizen92 in forum New To JavaReplies: 4Last Post: 01-12-2011, 09:41 PM -
total number of words starting with a vowel
By somnath6088 in forum New To JavaReplies: 4Last Post: 11-08-2010, 09:52 AM -
convert all vowels to the next alphabet and consonant to previous alphabet
By somnath6088 in forum New To JavaReplies: 2Last Post: 11-08-2010, 08:01 AM -
uppercase and lowercase please help
By cuziwow in forum New To JavaReplies: 4Last Post: 04-11-2010, 07:54 AM -
String uppercase/lowercase
By Java Tip in forum Java TipReplies: 0Last Post: 12-19-2007, 09:22 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks