Skip to content

Commit b9290d4

Browse files
lajitlajit
authored andcommitted
JAVA SAMPLE PROGRAMS UPDATE
1 parent e113fb3 commit b9290d4

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package learnSamplePrograms;
2+
3+
import java.util.Scanner;
4+
5+
public class TrianglePatterNumbers {
6+
7+
public static void main(String[] args) {
8+
9+
10+
Scanner scanner = new Scanner(System.in); //scan the entered value during runtime and store it
11+
System.out.println("Enter the number of values:"); // enter the number after executed this statement
12+
int enteredValue = scanner.nextInt(); //entered number is stored as integer in 'enteredValue' variable
13+
14+
/*for(int rows=1; rows<enteredValue; rows++) {
15+
16+
for(int column=1; column<=rows; column++) {
17+
System.out.print(column+"");
18+
}
19+
System.out.println();
20+
}*/
21+
22+
23+
// Use another method to print values from 1,2,3, etc on both the sides (rows and columns)
24+
25+
}
26+
27+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package learnSamplePrograms;
2+
3+
import java.util.Scanner;
4+
5+
public class TrianglePatternStar {
6+
7+
public static void main(String[] args) {
8+
// int rows, column = 0;
9+
10+
Scanner scanner = new Scanner(System.in); // scanner class is used to enter value during run-time
11+
12+
System.out.println("Enter number of lines to display:");
13+
14+
int numberOfLines = scanner.nextInt(); //get the value as integer during runtime
15+
16+
for(int rows=0; rows<numberOfLines; rows++) {
17+
18+
for(int column=0; column<=rows; column++) {
19+
System.out.print("* ");
20+
}
21+
22+
System.out.println("");
23+
24+
}
25+
26+
27+
}
28+
29+
}

0 commit comments

Comments
 (0)