In: Computer Science
Write a method that computes the number of lowercase letters (a-z) characters in a String:
The method signature is as follows: public int count(String s)
code:
import java.io.*;
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
Scanner s=new
Scanner(System.in);
System.out.println("Enter a
string");
String s1=s.next();
int lower=count(s1);
System.out.println(" Number of
Lower case letters : " + lower);
}
public static int count(String s1)
{
int lower=0;
for(int i = 0; i < s1.length(); i++)
{
char c =
s1.charAt(i);
if (c >= 'a'
&& c <= 'z')
lower++;
else
{
continue;
}
}
return lower;
}
}
thankyou