0

write a program to print total number of uppercase(distinct) in string. For example INPUT: HiHelloHowAreYou OUTPUT: 3

13th Jul 2017, 8:55 AM
kirubason
kirubason - avatar
2 Antworten
+ 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()); } }
13th Jul 2017, 9:36 AM
ChaoticDawg
ChaoticDawg - avatar
0
thank you bro
17th Jul 2017, 1:12 PM
kirubason
kirubason - avatar