Program -3 ||Punctuation Count String || JAVA ||Tutorial

preview_player
Показать описание
Java Program to count the total number of punctuation characters exists in a String

Explanation:
- Declare a string variable named "str" with the input string.
- Declare an integer variable named "count" to store the count of punctuation characters.
- Use a for loop to iterate through each character in the string. We will use our length() of String
- Check if the current character is a punctuation character using the logical OR operator and the equality operator. If the current character matches any of the punctuation characters (.,;:!?-), then increment the count variable by 1.
- Finally, print out the total number of punctuation characters in the string.
Рекомендации по теме
welcome to shbcf.ru