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
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.
i need to make a java program to play Yahtzee. it needs to use arrays. can you help me?
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...
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...
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]); }
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 HELP! Question: Write a Java console application that investigates how well Java handles large integers. Write two loops that iterate from 0 through 35. Before each loop, set an integer variable (IV) to 1. Within each loop, print the loop count and the value of IV formatted in two columns. Within the first loop, multiply IV by 2. Within the second loop, multiply IV by the appropriate StrictMath method. The second loop will not complete since there will eventually...
PLEASE READ THE FULL INSTRUCTION. Write a Java programme to print the pattern of asterisks shown below. For i=1 For i=2 * * For i=3 For i=n ** * ** ** ......... * (n asterisks) Your program should prompt the user to enter the value of n and then draw the corresponding star pattern. Remember if n is 5, you will have to print five patterns for i=1, i=2, i=3, i=4, and i=5. If n is 3, you will have...
Write a Java application that displays the following output pattern: Thus, there are+signs everywhere except the diagonal, which has". "signs. There are no blank characters. Requirements and Restrictions: The number of lines and the number of characters per line, i.e. the size of the square pattern and line argument. For example, the size of the above square is 11 and it is specified through the following compile and execute commands: e >javac PrintPattern.java > java PrintPattern 11 Your program should...