Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( PLEASE NOTE MY CODE BELOW, PRINTS THE FIRS TOP HALF OF THE DIAMOND ONE SPACE TOO CLOSE TO THE LEFT, I NEED TO KNOW

(PLEASE NOTE MY CODE BELOW, PRINTS THE FIRS TOP HALF OF THE DIAMOND ONE SPACE TOO CLOSE TO THE LEFT, I NEED TO KNOW WHY, AND NEED THE FIRST TOP HALF ONE SPACE OVER TO THE RIGHT)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_2

Step: 3

blur-text-image_3

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

Select suitable tools to analyze service problems.

Answered: 1 week ago