Computer Science, asked by freedelahoya04, 18 days ago

WAP to take 10 names, count and print how many names starts and ends with the same charceter.​

Answers

Answered by samarthkrv
1

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String[] names = new String[10];

    int x = 0;

 System.out.println("Enter all 10 names");

     for(int i = 0; i < 10; i++){

         names[i] = sc.nextLine();

     }

     for(int i = 0; i < names.length; i++){

         String str = names[i];

         int n = str.length();

         if(str.charAt(0) == str.charAt(n-1)){

             x++;

         }

     }

     System.out.println("The number of names with the starting and ending letter same is " + x);

}

}

Explanation:

Similar questions