Class Menu - Pat - ICSE - PROJECT
Class Menu - Pat - ICSE - PROJECT
Class Menu - Pat - ICSE - PROJECT
1 import java.util.*;
2 class Menu_Pat
3 {
4 public static void main(String args[])/**main function definition*
/
5 {
6 int i,j,k;/**variable declaration and initialization*/
7 char ch;
8 Scanner sc=new Scanner(System.in);/**object creation*/
9 System.out.println("Enter 'A' for pattern\nEnter 'B' for sum o
f series");
10 ch=sc.next().charAt(0);
11 switch(ch){/**starting of switch block*/
12 case 'A':/**starting of case 'A'*/
13 for(i=1;i<=6;i++)/**starting of outer for loop*/
14 {
15 for(j=2;j<=i;j++)
16 System.out.print(" ");
17 for(k=i;k<=6;k++)
18 {
19 if(k%2==0)
20 System.out.print("# ");/**displaying each elem
ent of the series*/
21 else
22 System.out.print("@ ");/**displaying each elem
ent of the series*/
23 }
24 System.out.println();
25 }/**end of outer for loop*/
26 break;
27 case 'B':/**starting of case 'B'*/
28 for(i=1;i<=5;i++)/**starting of outer for loop*/
29 {
30 for(j=1;j<=i;j++)
31 System.out.print(j*i+"\t");
32 System.out.println();
33 }/**end of outer for loop*/
34 break;
35 default:/**starting of default case*/
36 System.out.println("Wrong Choice");/**displaying the messa
ge*/
37 }/**end of switch block*/
38 }/**end of main method*/
39 }/**end of class Menu_Pat*/