Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Below is all 3 shapes. If someone can help me put it the way it is ask. This is

ID: 3882083 • Letter: B

Question

Below is all 3 shapes. If someone can help me put it the way it is ask.

This is the X pattern.

import java.util.Scanner;

class acdf {

public static void main(String[] args) {

Scanner s = new Scanner(System.in);

System.out.println("enter the number of rows=column");

int n = s.nextInt();

int i, j;

s.close();

for (i = 1; i <= n; i++) {

for (j = 1; j <= n; j++) {

if (j == i) {

System.out.print("*");

} else if (j == n - (i - 1)) {

System.out.print("*");

} else {

System.out.print(" ");

}

}

System.out.println();

}

}

}

The last one is the Diamond pattern

import java.util.Scanner;
public class newstar
{
public static void main(String agrs[])
{
Scanner in = new Scanner (System.in);

System.out.print("Enter Number: ");
int inp = in.nextInt();

int wan = 1;
int space = inp ;

for(int i = 0; i < inp; i++)
{
for(int s = 0; s < space ; s++)
{
System.out.print(" ");
}

for(int s = 0; s < wan ; s++)
{
if(s == 0 || s == wan-1)
{
System.out.print("*");
}
else
{
System.out.print(" ");

}

}

if(i == inp-1)
{
break;
}
else{
System.out.println();
wan=wan+2;
space--;
}


}


//second

int x = (inp * 2) - 1;

int y = 1;

for(int l = 1; l < inp; l++)
{
for(int s = y; s >= 1; s--)
{
System.out.print(" ");
}

for(int s = 0; s < x ; s++)
{
if(l >= 1)
{
if(s == 0 || s == x - 1)
{
System.out.print("*");
}
else
{
System.out.print(" ");
}

}

}
System.out.println();

x-=2;

y++;

}


}

}

1 public class Box 3 {public int size = 0; public void printBox() 6 {for(int i = 0; i

Explanation / Answer

import java.util.Scanner;
public class newstar
{
public static void main(String agrs[])
{
Scanner in = new Scanner (System.in);

System.out.print("Enter Number: ");
int inp = in.nextInt();

int wan = 1;
int space = inp ;

for(int i = 0; i < inp; i++)
{
for(int s = 0; s < space ; s++)
{
System.out.print(" ");
}

for(int s = 0; s < wan ; s++)
{
if(s == 0 || s == wan-1)
{
System.out.print("*");
}
else
{
System.out.print(" ");

}

}

if(i == inp-1)
{
break;
}
else{
System.out.println();
wan=wan+2;
space--;
}


}


//second

int x = (inp * 2) - 1;

int y = 1;

for(int l = 1; l < inp; l++)
{
for(int s = y; s >= 1; s--)
{
System.out.print(" ");
}

for(int s = 0; s < x ; s++)
{
if(l >= 1)
{
if(s == 0 || s == x - 1)
{
System.out.print("*");
}
else
{
System.out.print(" ");
}

}

}
System.out.println();

x-=2;

y++;

}


}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote