KnowledgeBoat Logo

Computer Applications

Write a program in Java to display the following pattern:

a a a a a
b b b b b
A A A A A
B B B B B

Java

Java Library Classes

60 Likes

Answer

public class KboatPattern
{
    public static void main(String args[]) {
        int a = 97;
        for (int i = 1; i <= 4; i++) {
            for (int j = 1; j <= 5; j++) {
                System.out.print((char)a + " ");
            }
            a++;
            if (i == 2)
                a = 65;
            System.out.println();
        }
    }
}

Variable Description Table

Program Explanation

Output

BlueJ output of Write a program in Java to display the following pattern: a a a a a b b b b b A A A A A B B B B B

Answered By

28 Likes


Related Questions