Question: 1 . 9 : Diamond Write an application that prints the following diamond shape. Don t print any unneeded characters. ( That is , don

1.9: Diamond
Write an application that prints the following diamond shape. Dont
print any unneeded characters. (That is, dont make any character
string longer than it has to be.)(You may need to scroll to see everything.)
*
***
*****
*******
*********
*******
*****
***
*1.9: Diamond
Write an application that prints the following diamond shape. Don't
print any unneeded characters. (That is, don't make any character
string longer than it has to be.)(You may need to scroll to see everything.)
SAMPLE RUN #0: java Diamond
4of4:2024-01-2511:19:39-Wvv
public class Diamond {
public static void main(String[] args){
int n=9;
// First half of diamond
for (int i=1;in2; i++){
// Print spaces on left side of each row
for (int j=1;jn2-i;j++){
System.out.print("");
}
// Print stars on each row
for (int j=1;j2**i-1;j++
System.out.print("*");
}
System.out.println();
}
// Second half of diamond
for (int i=n2+1; in; i++){
// Print spaces on left side of each row
for (int j=1;ji-n2-1;j++)
System.out.print("");
}
// Print stars on each row
for (int j=1;j2**(n-i)+1;j++
System.out.print("*");
System.out.println();
}
}
 1.9: Diamond Write an application that prints the following diamond shape.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!