How can I make this pattern in Java?
11 11
11 11
1111
11 11
11 11
Thanks for your help
Code:
public class Main
{
public static void main(String[] args) {
System.out.println("printing
the required pattern");//if you dont want to see this line put //
at the start of line
int n=5;//you can change this
n to observe changes in your pattern
int index;
for(int
i=0;i<n;i++){
if(i!=(n-1)/2){//if the row is not a middle row
index=(n-1)/2;//this stroes index of position to filled with empty
space
for(int j=0;j<index;j++){
System.out.print("1");//print 1
}
System.out.print(" ");//print space
for(int j=index+1;j<n;j++){
System.out.print("1");//print 1 in remaining positions
}
System.out.println("");//to move to next line
}//end of if
else{//if the row is middle row
for(int j=0;j<n-1;j++){
System.out.print("1");//print 1 in n-1 places
}
System.out.println(" ");//print a empty space and move to next line
println prints next string to next line
}//end of else
}//end of for
}//end of main function
}//end of class
Output:

How can I make this pattern in Java?
11 1 11 11 1111 11 11 11 11
Hi I would like to make a simple query rewriting program with Java. When I ask where question so for example, where (is the Louvre Museum located?) The answer would be the Louvre Museum is located in _____ like this Just change and re-phrase the sentence or more phrase changes if you think it is easy How can I make this simple code when users ask any where questions in prompt Please help me it would be great help to...
How can i code this with in java?
- $ java Graph 1 2 3 ( 1 2 3 - Java Graph 11 46 37 牛排 # # # | # # # # # # # # # # # # # # # # # # # | 11 46 37 Note: Spaces should be included to the end of each row.
need help with this physics question
Discuss how an N-slit pattern can be turned into a good spectrometer. Make sure to write a , sufficiently detailed essay that addresses the issue of the resolvability of wavelengths as well as the type of light source producing these wavelengths, and the size and geometry of the slit pattern. 3.
Discuss how an N-slit pattern can be turned into a good spectrometer. Make sure to write a , sufficiently detailed essay that addresses...
i need to make a java program to play Yahtzee. it needs to use arrays. can you help me?
I need help on Java Swing, how to create a Java Swing program that can able to Display all the name list from the text file then Display the Longest name...
How can I write in java to find the first power of 2 larger than n, if n is some number. Thanks
Develop a complete java program that produces a square pattern of asterisks and spaces. First prompt the user for the size of the pattern, then use for loops to print out the pattern. If the user enters a value that is not a number your program's behavior is arbitrary. For non-positive values your program should print nothing and end normally. Your program should work for input values up to the width of the terminal window. Examples for the first 6...
A single slit diffraction pattern shown above. The light used to
make the pattern has a wavelength of 521 nm and the screen is 1.8 m
from the slit. If the slit has a width 4 mm, what is the width w of
the central maximum in cm?
_____???
Please help solve this with work shown! Thanks!
初。。:
Java i know that result will be 415. Can you explain how it works. step by step please. thanks public static void whatsPrinted(int A[]) { for (int i=1; i<A.length; i++) { A[i]=A[i-1]*2+1; } } public static void main(String args[]) { int A[] = {12,3,8,9,7,11}; whatsPrinted(A); System.out.println(A[A.length-1]); }