Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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();
}
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago