Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save asanand3/2540123600d350b2def7 to your computer and use it in GitHub Desktop.

Select an option

Save asanand3/2540123600d350b2def7 to your computer and use it in GitHub Desktop.
public class ReadChars {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String text = scanner.nextLine();
for (int i = 0; i < text.length(); ) {
int temp = 0;
for (int j = 0; j < text.length(); j++) {
char a = text.charAt(i);
if (String.valueOf(a).toUpperCase().equals(String.valueOf(text.charAt(j)).toUpperCase())) {
temp++;
}
}
System.out.println(text.charAt(i) + " " + String.valueOf(temp));
temp = 0;
text= text.toUpperCase().replace(""+text.toUpperCase().charAt(i), "");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment