Java || Count The Total Number Of Characters, Vowels, & UPPERCASE Letters Contained In A Sentence Using A ‘For Loop’

Here is a simple program, which demonstrates more practice using the input/output mechanisms which are available in Java.

This program will prompt the user to enter a sentence, then upon entering an “exit code,” will display the total number of uppercase letters, vowels and characters which are contained within that sentence. This program is very similar to an earlier project, this time, utilizing a for loop, strings, and user defined methods.

REQUIRED KNOWLEDGE FOR THIS PROGRAM

How To Get String Input
If/Else Statements
For Loops
Methods (A.K.A "Functions") - What Are They?


QUICK NOTES:
The highlighted portions are areas of interest.

Notice line 22 contains the for loop declaration. The loop will continually loop thru the string, and will not stop doing so until it reaches an exit character, and the defined exit character in this program is a period (“.”). So, the program will not stop looping thru the string until it reaches a period.

Once compiling the above code, you should receive this as your output

Welcome to My Programming Notes' Java Program.

Enter a sentence, ending with a period:
My Programming Notes Is An Awesome Site.

Total number of upper case letters:........7
Total number of vowels:....................14
Total number of characters:................33

Was this article helpful?
👍 YesNo

Leave a Reply