Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java Programming using array

Have Programming Question? Ask it here!
 
 
 


Zofrente Valenzuela
Java Programming using array
1 Answer(s)      a year and 5 months ago
Posted in : Java Beginners


I'm creating a programming using array that will accept 10 letters and test if those letters are consonant, then it will display on the screen. Please guide me.

Sample Output:

Enter 10 letters.

A

B

C

D

E

F

G

H

I

J

The Consonants entered are

B

C

D

F

G

H

Program:

import java.io.*; public class Array {

public static void main(String args[]) throws IOException
{
    BufferedReader k = new BufferedReader(new InputStreamReader(System.in));
    char[] srcArray = new char[] = {'B', 'C', 'D', 'F', 'G','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z'};
    char ch=;
    System.out.println("Enter 10 letters");
    for(int x=0;x<10;x++)

    {
        System.out.println(k.readLine());
    }
    if(ch==char[x])
    {
        //Don't know what to put here now.
    }
    else
        System.out.println("Wrong Input!");
}

}

Help me out please.


Advertisement
View Answers

March 13, 2013 at 12:59 PM


hi friend,

Try this sample code may, this will be helpful for you.

    package net.roseindia;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class CheckForVowel {

    public static void main(String args[]) throws IOException
    {
        char n;

        BufferedReader s=new BufferedReader (new InputStreamReader
                (System.in));

        System.out.println ("Enter letters : ");
        String letter = s.readLine();
        for(int i=0; i<letter.length(); i++)
        {
        n= letter.charAt(i);        
        if (n=='a'|| n=='e'|| n=='i'|| n=='o'|| n=='u'|| n=='A'||
                n=='E'|| n=='I'|| n=='O'|| n=='U')
        System.out.println ("Vowel = "+n);
        else
        System.out.println ("Consonant = "+n); 
        }
    }
}


Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com