Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TextPlocessing.Lab;
- import java.util.Scanner;
- public class O5DigitsLettersAndOther {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- StringBuilder numbers = new StringBuilder(),
- letters = new StringBuilder(),
- special = new StringBuilder();
- for (int i = 0; i < input.length(); i++) {
- char symbol = input.charAt(i);
- if (Character.isDigit(symbol)) {
- numbers.append(symbol);
- } else if (Character.isAlphabetic(symbol)) {
- letters.append(symbol);
- } else {
- special.append(symbol);
- }
- }
- System.out.println(numbers);
- System.out.println(letters);
- System.out.println(special);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment