Page 300 - CA_Blue( J )_Class9
P. 300
17 j++;
18 }while(j<=4);
19 System.out.println(); //allows to print in the next line
20 i++;
21 }while(i<=n);
22 }
23 }
You will get the following output:
Enter number of lines : 4
1234
1234
1234
1234
VARIABLE DESCRIPTION
NAME DATATYPE DESCRIPTION
n int Number of Lines
i int Loop Variable
j int Loop Variable
(x) Menu-Driven programs
Write a menu-driven program to do the following:
Using the switch statement, write a menu-driven program for the following:
(a) To print Floyd's triangle:
Program 22
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
(b) To display the following pattern:
A
A B
A B C
A B C D
For an incorrect option, an appropriate error message should be displayed.
1 import java.util.*; //importing “util” package
2 class menu // class name
3 {
4 public static void main()
5 {
6 Scanner sc = new Scanner(System.in);
298 Touchpad Computer Applications-IX

