-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiffchars.java
More file actions
25 lines (22 loc) · 856 Bytes
/
diffchars.java
File metadata and controls
25 lines (22 loc) · 856 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
import java.util.Scanner;
public class diffchars {
public static void main(String[] args) {
System.out.println("Enter a String to count and list different characters");
Scanner sc = new Scanner(System.in);
String Str = sc.nextLine();
String upperStr = Str.toUpperCase();
// System.out.println("Entered String is "+upperStr);
int count =0;
System.out.println("Different Characters used to form this string are : ");
for(char ch='A';ch<='z';ch++){
for (int i=0;i< upperStr.length();i++){
if (ch == upperStr.charAt(i)){
count++;
System.out.print(ch+" ");
break;
}
}
}
System.out.println("\n Total numbers of different characters used are :"+count);
}
}