Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ElectronicMessage {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String [] input = scan.nextLine().split(" ");
- int counter = 0;
- int tempCounter = 0;
- String allWords = "";
- for (int i = 0; i < input.length; i++) {
- allWords = input[i];
- String specialCharactersString = "!@#$%^&*()_+-=><?";
- for (int k = 0; k < allWords.length(); k++) {
- char ch = allWords.charAt(k);
- if (specialCharactersString.contains(Character.toString(ch))) {
- tempCounter++;
- }
- if ((Character.toString(ch)).matches(".*[a-zA-Z].*") ||
- (Character.toString(ch)).matches(".*[0-9].*")) {
- if (counter < tempCounter) {
- counter = tempCounter;
- }
- tempCounter = 0;
- }
- }
- if (counter < tempCounter) {
- counter = tempCounter;
- }
- tempCounter = 0;
- }
- System.out.println(counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement