Computer Applications
Write a program in Java that reads a word and checks whether it begins with a vowel or not.
Java
Java Conditional Stmts
5 Likes
Answer
import java.util.Scanner;
public class KboatWord
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a word: ");
String w = in.nextLine();
char ch = w.charAt(0);
ch = Character.toUpperCase(ch);
if (ch == 'A' ||
ch == 'E' ||
ch == 'I' ||
ch == 'O' ||
ch == 'U')
System.out.println("Word begins with a vowel");
else
System.out.println("Word does not begin with a vowel");
}
}
Output
Answered By
3 Likes
Related Questions
Write a program in Java to read three integers and display them in descending order.
Create a program to find out if the number entered by the user is a two, three or four digits number.
Sample input: 1023
Sample output: 1023 is a 4 digit number.Write a program to find the number of and sum of all integers greater than 500 and less than 1000 that are divisible by 17
Using the ternary operator, create a program to find the largest of three numbers.