-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLettercheck.java
More file actions
31 lines (25 loc) · 1.05 KB
/
Lettercheck.java
File metadata and controls
31 lines (25 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.*;
public class Lettercheck{
public static void main(String[] args) {
// Insert the scanner class
Scanner input = new Scanner(System.in);
//Read input as letter variable
String letter;
//Create a loop to check if user has put in a letter
do {
//Ask the user for a letter
System.out.print("Enter a letter to check if it is a Consonant or a vowel: ");
//Retreive the input from the user
letter= input.nextLine();
}
//Check if user has put in a letter
while (!letter.matches("[a-zA-Z]"));
//check if letter is vowel or consonant
if (letter.matches("[aeiouAEIOU]")) {
System.out.print("This is a vowel");
} else {
System.out.print("This is a consonant");
}
input.close();
}
}