Results 1 to 9 of 9
Like Tree1Likes
  • 1 Post By Iron Lion

Thread: how to determine if uppercase vowel or consonant, lowercase vowel or consonant, etc

  1. #1
    Join Date
    Aug 2011
    Posts
    5
    Rep Power
    0

    Post 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..

    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");
    					}
    kindly check my code if it is correct or if there's any error..

    thanks in advance..
    Last edited by mariahfrancheszca; 08-17-2011 at 07:05 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default

    kindly check my code if it is correct or if there's any error.
    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.

    db

  3. #3
    Join Date
    Aug 2011
    Posts
    5
    Rep Power
    0

    Post 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

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    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.

  5. #5
    Join Date
    Aug 2011
    Posts
    5
    Rep Power
    0

    Default

    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..

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    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

  7. #7
    Join Date
    Aug 2011
    Posts
    5
    Rep Power
    0

    Default

    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:
    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");
    			}
    			}
    thanks.. do i need to add some statements or methods?. can you help me with this?. thanks a lot..

  8. #8
    Join Date
    Aug 2011
    Posts
    5
    Rep Power
    0

    Default

    i need your help.. please. thanks..

  9. #9
    Iron Lion is offline Senior Member
    Join Date
    Nov 2010
    Posts
    210
    Rep Power
    5

Similar Threads

  1. vowel couting
    By aizen92 in forum New To Java
    Replies: 4
    Last Post: 01-12-2011, 10:41 PM
  2. total number of words starting with a vowel
    By somnath6088 in forum New To Java
    Replies: 4
    Last Post: 11-08-2010, 10:52 AM
  3. Replies: 2
    Last Post: 11-08-2010, 09:01 AM
  4. uppercase and lowercase please help
    By cuziwow in forum New To Java
    Replies: 4
    Last Post: 04-11-2010, 08:54 AM
  5. String uppercase/lowercase
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-19-2007, 10:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •