Question

How can I make this pattern in Java?

11 1 11 11 1111 11 11 11 11

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;

public class Main
{
   public static void main(String[] args) {
      
   int i, j;
for(i=1; i<=5; i++) // itereates over row
{
for(j=1; j<=6; j++) // itereates over columns
{
if(j==i || (j==5 - i + 1))
{
if(i == 3)
System.out.print("1111");
else if(j >= 3)
System.out.print(" 11");
else
System.out.print("11");
}
else
{
System.out.print(" ");
}
}

System.out.println();
}
      
   }
}

OUTPUT :

9 input 11 11 11 11 1111 11 11 11 11 ... Program finished with exit code 0 Press ENTER to exit console. I

Add a comment
Know the answer?
Add Answer to:
How can I make this pattern in Java? 11 1 11 11 1111 11 11 11...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT