-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlphabet.java
More file actions
26 lines (23 loc) · 801 Bytes
/
Alphabet.java
File metadata and controls
26 lines (23 loc) · 801 Bytes
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
import java.util.Scanner;
public class Alphabet {
public static void main (String[]args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter a sentence:");
String sentence = sc.nextLine();
String newSentence = sentence.toLowerCase();
String result = whatsMissing(newSentence);
System.out.println("Missing letters: " + result);
sc.close();
}
static String whatsMissing (String line){
String alph = "abcdefghijklmnopqrstuvwxyz";
for(int x = 0; x < line.length(); x++){
char c = line.charAt(x);
String s = Character.toString(c);
if (alph.contains(s)){
alph = alph.replace(s, "");
}
}
return alph;
}
}