Home ICSE Computer Applications Class 10 – Previous Year Question Papers & Solutions / Programs / Define a class to declare an array to accept and store ten words. Display only those words which begin with the letter 'A' or 'a' and also end with the letter 'A' or 'a'.EXAMPLE :Input : Hari, Anita, Akash, Amrita, Alina, Devi Rishab, John, Farha, AMITHAOutput: AnitaAmritaAlinaAMITHA
🚀 Programming Example

Define a class to declare an array to accept and store ten words. Display only those words which begin with the letter 'A' or 'a' and also end with the letter 'A' or 'a'.
EXAMPLE :
Input : Hari, Anita, Akash, Amrita, Alina, Devi Rishab, John, Farha, AMITHA
Output: Anita
Amrita
Alina
AMITHA

👁 72 Views
💻 Practical Program
📘 Step Learning
Learn this program step-by-step with algorithm, source code, output and detailed explanation.
No previous program
No next program

📌 Information & Algorithm

Given Input:


Expected Output:


💻 Program Code

import java.util.Scanner;

public class RansariWords
{
    public static void main(String args[]) 
    {
        Scanner in = new Scanner(System.in);
        String names[] = new String[10];
        int l = names.length;
        System.out.println("Enter 10 names : ");
        
        for (int i = 0; i < l; i++) 
        {
            names[i] = in.nextLine();
        }
        
        System.out.println("Names that begin and end with letter A are:");

        for(int i = 0; i < l; i++)
        {
            String str = names[i];
            int len = str.length();
            char begin = Character.toUpperCase(str.charAt(0));
            char end = Character.toUpperCase(str.charAt(len - 1));
            if (begin == 'A' && end == 'A') {
                System.out.println(str);
            }
        }
    }
}
                        
No previous program
No next program
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.