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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!