Computer Science, asked by darshanabalamurali6, 9 months ago

*
***
*****
*******
*****
***
*
Write a java program to display this pattern. If the answer is right I'll mark it as the brainliest answer​

Answers

Answered by brainstrom1
1
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int x=0;
for(int i=0;iif(i<=n/2){
if(n%2==0 && i==n/2){
x-=1;
}
else
x+=1;
for(int j=0;jSystem.out.print('*');
System.out.println();
if(n%2==0 && i==n/2){
x+=1;
}
}
else{
for(int j=0;jSystem.out.print('*');
System.out.println();
x-=2;
}
}
}
}

/* Works perfectly for both even and odd inputs (for the question give input as 7) (**mark brainliest)*/
// Contact me for similar questions
Similar questions