Computer Science, asked by anushka7755, 5 months ago

write pattern program using switch case in java
i-54321
5432
543
54
5


ii-AAAAA
BBBB
CCC
DD
E

Answers

Answered by BrainlyProgrammer
2

Question:-

  • write pattern program using switch case in java

54321

5432

543

54

5

AAAAA

BBBB

CCC

DD

E

Answer:-

//CODE WRITTEN BY @swetank232894

import java.util.*;

class Code

{

public static void main (String ar[])

{

Scanner sc=new Scanner (System.in);

System.out.println("Enter 1 for Pattern 1 and 2 for Pattern 2");

int ch=sc.nextInt();

switch (ch)

{

case 1: for(I=1;I<=5;I++)

{

for(j=5;j>=I;j--)

{

System.out.print(j);

}

System.out.println();

}

break;

case 2: for(I=65;I<=69;I++)

{

for(j=69;j>=I;j--)

{

System.out.print((char)(I));

}

System.out.println();

}

break;

default: System.out.println("Wrong Input");

}

//end of switch block

}//end of main()

}//end of class

Similar questions