Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

* Converts a string to lowercase, * and displays the string\'s length * as well

ID: 3722108 • Letter: #

Question

* 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);

}

}

Explanation / Answer

public class LowerCaseString

{

public static void main(String[] args)

{

String newstr,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();

str = str.toLowerCase();

System.out.print("In all lowercase, the sentence is: "+str);

for(int i = 0; i < stringLength; i++)

{

char c = str.charAt(i);

if(Character.isLetter(c))

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: " + numLetters);

}

}