Question
* Converts a string to lowercase, * and displays the string's length * as well as a count of letters */ /*The program should produce
* Converts a string to lowercase,
* and displays the string's length
* as well as a count of letters
*/
/*The program should produce the following outupt once all the bugs are fixed.
* Output:
* In all lowercase, the sentence is: "debugging is fun!!!"
* The number of CHARACTERS in the string is: 19
* The number of LETTERS is: 14
*/
public class LowerCaseString
{
public static void main(String[] args)
{
String str = "Debugging is FUN!!!";//input string that needs to be converted to lowercase
int numLetters = 0;
//converts string to lower case and counts number of letters
int stringLength = str.length;
System.out.print("In all lowercase, the sentence is: \"");
for(int i = 0; i < length; i++)
{
char ch = Character.toLowerCase(str[i]);
System.out.print(ch);
if(Character.isLetter())
numLetters++;
}
//printing number of letters and characters
System.out.println("\"");
System.out.println("The number of CHARACTERS in the string is: " + stringLength);
System.out.println("The number of LETTERS is: " + stringLength);
}
}
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