please help me to solve this question about array

Ads
 

please help me to solve this question about array

write a program thatt stores vowels (a,e,i,o and u)in an array. Ask the user to enter any character. The program should ignore the case of that character (uppercase or lowercase) and determine whether the entered character is vowel or not.

View Answers

November 9, 2010 at 3:42 PM

import java.util.Scanner;

public class Example1 {

public static void main(String[] args) {
    char arr[] = { 'a', 'e', 'i', 'o', 'u' };
    String brr;
    boolean flag = false;
    Scanner sc = new Scanner(System.in);
    char ch;
    System.out.println("Enter any character:");
    brr = sc.nextLine();
    if (brr.length() > 1)
        System.out.println("It is not character. Please enter character");
    else {
        ch = brr.charAt(0);
        System.out.println("It is character. " + ch);
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == ch) {
                flag = true;
                break;
            }
        }
        if (flag)
            System.out.println(ch + " is vowel.");
        else
            System.out.println(ch + " is consonant.");
    }
}

}

Is this code is fruitful for you.

+++++++++ knapster +++++++++


November 9, 2010 at 4:25 PM

import java.util.Scanner;

public class Example1 {

public static void main(String[] args) {
    char arr[] = { 'a', 'e', 'i', 'o', 'u' };
    String brr;
    boolean flag = false;
    Scanner sc = new Scanner(System.in);
    char ch;
    System.out.println("Enter any character:");
    brr = sc.nextLine();
    if (brr.length() > 1)
        System.out.println("It is not character. Please enter character");
    else {
        ch = brr.toLowerCase().charAt(0);
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == ch) {
                flag = true;
                break;
            }
        }
        if (flag)
            System.out.println(brr + " is vowel.");
        else
            System.out.println(brr + " is consonant.");
    }
}

}

Ads









Related Tutorials/Questions & Answers:
please help me to solve this question about array
please help me to solve this question about array  write a program thatt stores vowels (a,e,i,o and u)in an array. Ask the user to enter any...() > 1) System.out.println("It is not character. Please enter
help me to solve this question
help me to solve this question  Write a program that inputs a series of integers into an array. The numbers are in the range 0 to 100. Calculate and display : a) The Largest number b) The Smallest Number c)The sum of the numbers
Advertisements
help me to solve this question...
help me to solve this question...  Given below is a class definition... and then create an array name myLibrary of type Book with size n. Using loop, create n objects of type Book and put them in the array myLibrary after reading the title
help me to solve this question
help me to solve this question   A user needs to key in data into system in order to save data into array. The data are: a. Lecturer ID, Lecturer... that has been added into array with the following features: a. Edit the course
please help me to answers this question about C++.....huuhuhuhu
please help me to answers this question about C++.....huuhuhuhu  1... 3023 mark) and manipulate it by reading information to an array of student...; } } int main() { int *array; int size; cout <<
please help me to answers this question about C++.....huuhuhuhu
please help me to answers this question about C++.....huuhuhuhu  1... 3023 mark) and manipulate it by reading information to an array of student...; } } int main() { int *array; int size; cout <<
help me about to solve my qustion
help me about to solve my qustion   An employee receives 15 SR per hour for the first 8 hours of week. After 8 hours (overtime) his rate becomes 20 SR per hour . Write a java class that ask a user to enter the number of hours he
CAN ANYONE SOLVE THIS FOR ME. URGENT HELP NEEDED. PLEASE HELP
CAN ANYONE SOLVE THIS FOR ME. URGENT HELP NEEDED. PLEASE HELP   The Task Write a class whose objects will represent students... in case you change your mind about something and want to go back
CAN ANYONE SOLVE THIS FOR ME. URGENT HELP NEEDED. PLEASE HELP
CAN ANYONE SOLVE THIS FOR ME. URGENT HELP NEEDED. PLEASE HELP   Write a class whose objects will represent students.The class should have three... about something and want to go back to an earlier version
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  1) Copy one file content to other? 2) Count the number of words in a file
help me please
help me please   Hello I want helping for this question , Please Write a program that reads some friendsââ?¬â?¢ names, stores them in an array, and then prints out on the screen all friends who start by a particular letter
help me to solve this problem..
help me to solve this problem..  Given below is a class definition... and then create an array name myLibrary of type Book with size n. Using loop, create n objects of type Book and put them in the array myLibrary after reading the title
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  Q 1) In a class first day 25 students are joined. After two days that total students will increased to 60. We can develop a program by using ArrayList concept
urgent...pleAse help me.....please!
urgent...pleAse help me.....please!  please help me urgent! how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
I really need help with this assignment question Please help me out Please
I really need help with this assignment question Please help me out Please  * Description* You are hired to develop a laptop inventory information system for Sheridan College in order to keep track of the information about
please help me.
please help me.  I have three table in mysql,and i hava create a excel sheet and add this sheet.but my question is in every sheet i can display one one table result.how can i do
please help me.
please help me.  Please send me a code of template in opencms and its procedure.so i can implement the code. Thanks trinath
please help me.
please help me.  How to read a properties file in java with a suitable example. Please send me. Thanks Trinath   Please visit the following link: Java read properties file
please help me.
please help me.  Please send me the validation of this below link. the link is http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html Thanks Trinath
please help me.
please help me.  How to move the edits.jsp in below link? http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html
help me please
help me please  how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
Please help me??
Please help me??  Question_1: Using one-dimension array of primitive... to declare, create and manipulate a one-dimension array of primitive type... two integer array called array1 and array2 3. For array1, set initial values
Please Help To Solve My Problem
Please Help To Solve My Problem  PHP I Have 6 Textbox and 1 ok... With B Team when A Team Play With B Team Again Then Generate Error. I Am Solve... Are There Then It's Large Codding So I Need To Help To Another Way To Do
please help me.
please help me.  I have a jsp page under that i add a list box under i get the countries through my database. so how can i do
please please i wanna insertion sort program find calendar to array value (1000,5000,10000), please help me
Insertion sort program find calendar to array value 1000,5000,10000  program find calendar for insertion sort in jfram to array 1000
please help me
before. This name list should get from the database. Please help me. By the way, I'm...please help me  Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another
Please help me.
Please help me.  Hi i am trinath in below there is a url.In that url there is a code of edit a jsp page.I understand that code but only one thing i not get it i.e; What is the work of "id".and what is the data type of id? http
please help me...
please help me...  write an application that print number in the following order using a FOR-Loop 1 2 3 4 5 2 4 6 8 10 3 6 9 1215 4 8 121620 5 10152025
please help me in these prog
please help me in these prog   create 2 jdbc programs including awt create 2 jdbc programs including swing create 2 jdbc programs including command line argument create 2 jdbc programs including io class 4 jdbc prog using
please help me to this problem..
please help me to this problem..  i wrote a program like keyboard... inside the JTextField) but i want to make this program to let me write where i clicked (i.e allows me to write any thing at the field where i clicked
Please help me out
Please help me out    Description* You are hired to develop a laptop inventory information system for Sheridan College in order to keep track of the information about the laptops lent to the students. Users can add or remove data

Ads