Vowel - if Learn programming Java

Lesson:

Basic Data Types


Exercise:

Vowel - if 12


Objetive:

Create a java program to ask the user for a symbol and answer if it is a (lowercase) vowel, a digit, or any other symbol, using "if".


Code:

import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		char symbol;

		System.out.print("Enter a symbol: ");
		symbol = (char)new Scanner(System.in).nextLine();

		if ((symbol == 'a') || (symbol == 'e') || (symbol == 'i') || (symbol == 'o') || (symbol == 'u'))
		{
			System.out.println("It's a lowercase vowel.");
		}
		else if ((symbol >= '0') && (symbol <= '9'))
		{
			System.out.println("It's a digit.");
		}
		else
		{
			System.out.print("It's another symbol.");
		}
	}
}