Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner keyboard= new Scanner(System.in);
- String input;
- System.out.print("please enter a letter: ");
- input = keyboard.nextLine();
- if (input.length() == 1)
- {
- if(input.equalsIgnoreCase("A") || input.equalsIgnoreCase("E")
- ||input.equalsIgnoreCase("I")||input.equalsIgnoreCase("O")
- || input.equalsIgnoreCase("U"))
- {
- System.out.println("the letter "+input+" is a vowel.");
- }
- else
- {
- System.out.println("the letter "+input+" is a consonant.");
- }
- }
- else
- {
- System.out.println("Error. That is not a single letter."
- +" Please run the program again and enter a single letter.");
- }
- keyboard.close();
Add Comment
Please, Sign In to add comment