السؤال هـو
. Write a program to read a string and then count the number of small letters ('a'..'z') in that string.
كيف احسب جميع الحروف الصغيره
الحل اللي تحت لحساب حرفين فقط
import java.util.*;
public class sheet4_q2{
static Scanner console = new Scanner(System.in);
public static void main(String[] args){
int a= 0, z = 0;
String str;
char c;
System.out.println("Enter a sentence");
str = console.nextLine();
for ( int num =0 ; num<str.length(); num++)
{
c =str.charAt(num);
if (a == 'a')
a++ ;
else if ( z == 'z')
z++;
}
System.out.print("the number of a is" + a + "\n" );
System.out.print("the number of z is" + z);
}
}
