Create a program that Prompt the user to enter three differentquotes. *Use a loop to get these three different quotes (don’t justprompt three times). And display the total number of spacescontained in the String. Save the file as CountMovieSpaces2.java.Loop through the string and count the spaces.
String theQuote;
int stringLength;
stringLength = theQuote.length();
Once we have the length we can loop through the string with a forloop.
char ch = theQuote.charAt(i); //i is the index used in the forloop
You can now test that ch. if (ch == ‘ ‘) {
increment a variable such as numberOfSpaces
}
Sample output:
Enter a movie quote >> This is a quote from
PayPal Gateway not configured
PayPal Gateway not configured