0
write a program to print total number of uppercase(distinct) in string. For example INPUT: HiHelloHowAreYou OUTPUT: 3
2 Answers
+ 1
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class DistictUppercase {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char[] input = sc.nextLine().toCharArray();
Set<Character> chars = new HashSet<>();
for(char c: input) {
if(Character.isUpperCase(c)) {
chars.add(c);
}
}
System.out.println(chars.size());
}
}
0
thank you bro