This preview shows page 1. Sign up to view the full content.
Unformatted text preview: sum); } /* Problem 8, p.229: Write a loop that will count the number of blank characters in a given string (Store the number of blanks in the variable numBlanks) */ System.out.print("Enter a string: "); String myString = keyboard.next(); int numBlanks = 0; /* Problem 8: Put your code here */ /* Note: myString.length() gives the number of characters in myString myString.charAt(i) gives the character at index i of myString */ System.out.println("The number of blank characters in that string was " + numBlanks); } }...
View Full Document
- Spring '08
- C Programming