Question
//CountMovieSpaces.java public class CountMovieSpaces { public static void main(String[]args) { //declare a string to read movie quote String movieQuote=They say that the best blaze burns
//CountMovieSpaces.java public class CountMovieSpaces { public static void main(String[]args) { //declare a string to read movie quote String movieQuote="They say that the best blaze burns brightest when circumstances are at their worst."; /*declare an integer and initialize to zero to count spaces.*/ int spaceCount=0; /*Iterate over the movieQuote string to find spaces.*/ for (int index = 0; index < movieQuote.length(); index++) { if(Character.isSpace(movieQuote.charAt(index))) //increment the count of spaceCOUNT by one spaceCount=spaceCount+1; } //print movie quote System.out.printIn("Movie Quote: "+movieQuote); //print spaces count System.out.printIn("Number of spaces in quote: "+spaceCount);
}
PLEASE HELP! I am not sure what I did wrong with this java code!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started