0% found this document useful (0 votes)
4 views2 pages

Java Patterns with Numbers and Letters

The document contains multiple Java code snippets that demonstrate different patterns of output based on user input. Each snippet uses nested loops to print either numbers, asterisks, or letters in a specific format. The patterns vary in alignment and character used, showcasing different approaches to formatting console output.

Uploaded by

czxc650
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Java Patterns with Numbers and Letters

The document contains multiple Java code snippets that demonstrate different patterns of output based on user input. Each snippet uses nested loops to print either numbers, asterisks, or letters in a specific format. The patterns vary in alignment and character used, showcasing different approaches to formatting console output.

Uploaded by

czxc650
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Scanner sc = new Scanner(System.

in);
int n = [Link]();
int x=1;

for (int i = 1; i < n; i++) {

for (int j = 0; j < i; j++) {


[Link](x);
x++;
}
x=1;
for (int j = 0; j < n - i; j++) {
[Link](" ");
}
[Link]();
}
}
--------------------------------------------------------
Scanner sc = new Scanner([Link]);
int n = [Link]();
int x=1;

for (int i = 1; i < n; i++) {

for (int j = 0; j < i; j++) {


[Link](x);
x++;
}

for (int j = 0; j < n - i; j++) {


[Link](" ");
}
[Link]();
}
}
-------------------------------------------
Scanner sc = new Scanner([Link]);
int n = [Link]();

for (int i = 1; i <= n; i++) {

for (int j = 0; j < i; j++) {


[Link]('*');

for (int j = 0; j < n - i; j++) {


[Link](' ');
}
[Link]();
}
}
------------------------------------------
Scanner sc = new Scanner([Link]);
int n = [Link]();

for (int i = 1; i <= n; i++) {


for (int j = 0; j < n - i; j++) {
[Link](' ');
}
for (int j = 0; j < i; j++) {
[Link]('*');

}
[Link]();
}
}
---------------------------------------------------
Scanner sc = new Scanner([Link]);
int n = [Link]();
char let = 'a';

for (int i = 1; i <= n; i++) {

for (int j = 0; j < i; j++) {


[Link](let);
let++;
}
let='a';
for (int j = 0; j < n - i; j++) {
[Link](' ');

}
[Link]();
}
}
--------------------------------------
Scanner sc = new Scanner([Link]);
int n = [Link]();
char let = 'a';

for (int i = 1; i <= n; i++) {

for (int j = 0; j < i; j++) {


[Link](let);
let++;
}

for (int j = 0; j < n - i; j++) {


[Link](' ');

}
[Link]();
}
}

You might also like