Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

image text in transcribed

image text in transcribed

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

for (j = 1; 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

for(int s = 0; s

}

}

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 = 1; s--) { System.out.print(" "); }

for(int s = 0; s = 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

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

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions