A company has launched a new text editor that allows users to enter English letters, numbers and whitespaces only. If a user attempts to enter any other type of character, it is counted as a miss. Given a string of text, write an algorithm to help the developer detect the number of misses by a given user in the given input.
Input
The input consists of a string textinput, representing the text that is entered in the text editor by the user.
Output
Print an integer representing the number of misses by a given user in the given input.
Example
Input:
aa a234bc@ sads hsagd^
Output:
3
Explanation:
The characters that are counted as misses by the editor are l’@’s.]
Solution
def editorMisses(textinput):
count = 0
for i in textinput:
if i.isalpha() == False and i.isdigit() == False and i.isspace() == False:
count += 1
return count public static int editorMisses(String input) {
int miss = 0;
for (int i = 0; i < input.length(); i++) {
if (!Character.isLetterOrDigit(input.charAt(i)) && !Character.isWhitespace(input.charAt(i))) {
miss++;
}
}
return miss;
}Happy Learning – If you require any further information, feel free to contact me.
![[Solved] A company has launched a new text editor that allows users to enter English letters [Solved] A company has launched a new text editor that allows users to enter English letters](https://realcoder.techss24.com/wp-content/uploads/2022/11/Solved-A-company-has-launched-a-new-text-editor-that-allows-users-to-enter-English-letters.png)
![[Solved] Newton has shifted to a new house and it came to his notice](https://realcoder.techss24.com/wp-content/uploads/2023/01/Solved-Newton-has-shifted-to-a-new-house-and-it-came-to-his-notice-300x196.png)
![[Solved] Series The Event Organizing Company with Java, C++, Python](https://realcoder.techss24.com/wp-content/uploads/2023/02/Solved-Series-The-Event-Organizing-Company-with-Java-C-Python-300x169.png)
![[Solved] Game of Love CodeCrush by NewtonSchool](https://realcoder.techss24.com/wp-content/uploads/2023/02/Solved-Game-of-Love-CodeCrush-by-NewtonSchool-300x169.png)