0% found this document useful (0 votes)
21 views3 pages

Activities: Void String Scanner System System Int Int Int System Int System System

The document contains a daily schedule and code examples to print triangle star patterns in Java including an upward triangle, downward triangle, and diamond pattern using loops and conditional statements.

Uploaded by

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

Activities: Void String Scanner System System Int Int Int System Int System System

The document contains a daily schedule and code examples to print triangle star patterns in Java including an upward triangle, downward triangle, and diamond pattern using loops and conditional statements.

Uploaded by

2018icts71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Activities hours

English podcast 8.00-9.00

Polymorphism-exercise 9.00-12.00

Lunch 12.00-2.30
personal work 12.30 -2.00

Pattern 2.00-5.00

Head java first[Form page number 75] 5.00-6.00

Dinner 7.30-8.00

Evining class(Questions revision,and oop introduction) 8.15-9.00

Recap previous notes 9.00-10.30

I watched youtube tutorial 10.30-11.00

1.Triangle Star Pattern

public static void main(String[] args) {


Scanner scan=new Scanner(System.in);
System.out.print("How many Rows do you want:");
int rows=scan.nextInt();

for(int i=1;i<=rows;i++){
for(int k=rows;k>=i;k--){
System.out.print(" ");
}
for(int j=1;j<=i;j++){
if(j==1||j==i){
System.out.print("*");
}else if(rows==i){
System.out.print("* ");
}
else{
System.out.print(" ");
}

}
System.out.println();
}
}

2.Down Triangle Pattern


public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
System.out.print("How many Rows do you want:");
int rows=scan.nextInt();

for(int i=rows;i>=1;i--){
for(int k=rows;k>=i;k--){
System.out.print(" ");
}
for(int j=i;j>=1;j--){
if(j==1||j==i){
System.out.print("*");
}else if(rows==i){
System.out.print("* ");
}
else{
System.out.print(" ");
}

}
System.out.println();
}
}

3.Diamond Triangle

public static void main(String[] args) {


Scanner scan=new Scanner(System.in);
System.out.print("How many Rows do you want:");
int rows=scan.nextInt();

for(int i=1;i<=rows;i++){
for(int k=rows;k>=i;k--){
System.out.print(" ");
}
for(int j=1;j<=i;j++){
if(j==1||j==i){
System.out.print("*");
}
else{
System.out.print(" ");
}
}
System.out.println();
}

for(int i=rows-1;i>=1;i--){
for(int k=rows;k>=i;k--){
System.out.print(" ");
}
for(int j=i;j>=1;j--){
if(j==1||j==i){
System.out.print("*");
}
else{
System.out.print(" ");
}

}
System.out.println();
}
}

You might also like