1. Write a java program for the below star pattern?
*
* *
* * *
* * * *
* * * * *
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | package in.studyecart.basics.datatypes; import java.util.Scanner; public class Lab { public static void main(String[] args) { Scanner input=new Scanner(System.in); // scan an input number for now of rows System.out.println("Please Enter how rows you want:"); int n=input.nextInt(); //print the pattern //Rows for(byte row=0;row<n;row++) { //columns for(byte colmn=0;colmn<=row;colmn++) { System.out.print("*"); } //new line after every row System.out.println("\n"); } } } |
2. Write a java program for the below star pattern?
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | package in.studyecart.basics.datatypes; import java.util.Scanner; public class Pattern2 { public static void main(String[] args) { Scanner input=new Scanner(System.in); // scan an input number for now of rows System.out.println("Please Enter how rows you want:"); byte n=input.nextByte(); //print the pattern //Rows for(byte row=n;row>=0;row--) { //columns for(byte colmn=row;colmn>=0;colmn--) { System.out.print("*"); } //new line after every row System.out.println("\n"); } } } |
3. Write a java program for the below star pattern?
A
A A
A A A
A A A A
A A A A A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | package in.studyecart.basics.datatypes; import java.util.Scanner; public class Pattern3{ public static void main(String[] args) { Scanner input=new Scanner(System.in); // scan an input number for now of rows System.out.println("Please Enter how rows you want:"); byte n=input.nextByte(); // take character in a variable ch char ch='A'; //print the pattern //Rows for(byte row=0;row<=n;row++) { //columns for(byte colmn=0;colmn<=row;colmn++) { System.out.print(ch+" "); } //new line after every row System.out.println("\n"); } } } |
4. Write a java program for the below star pattern?
A
A B
A B C
A B C D
A B C D E
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | package in.studyecart.basics.datatypes; import java.util.Scanner; public class Pattern4{ public static void main(String[] args) { Scanner input=new Scanner(System.in); // scan an input number for now of rows System.out.println("Please Enter how rows you want:"); byte n=input.nextByte(); //print the pattern //Rows for(byte row=0;row<=n;row++) { // take character in a variable ch char ch='A'; //columns for(byte colmn=0;colmn<=row;colmn++) { System.out.print(ch+" "); ch++; } //new line after every row System.out.println("\n"); } } } |
5. Write a java program for the below star pattern?
A
B C
D E F
G H I
J K L M
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | package in.studyecart.basics.datatypes; import java.util.Scanner; public class Pattern5{ public static void main(String[] args) { Scanner input=new Scanner(System.in); // scan an input number for now of rows System.out.println("Please Enter how rows you want:"); byte n=input.nextByte(); // take character in a variable ch char ch='A'; //print the pattern //Rows for(byte row=0;row<n;row++) { //columns for(byte colmn=0;colmn<=row;colmn++) { System.out.print(ch+" "); ch++; } //new line after every row System.out.println("\n"); } } } |
6. Write a Java Program for the below Star Pattern?
1
2 3
4 5 6
7 8 9 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | package in.studyecart.basics.datatypes; import java.util.Scanner; public class Pattern6{ public static void main(String[] args) { // take character in a variable ch char ch=48; //print the pattern //Rows for(byte row=0;row<=3;row++) { //columns for(byte colmn=0;colmn<=row;colmn++) { System.out.print(ch+" "); ch++; } //new line after every row System.out.println("\n"); } } } |