Drawing a rectangle

  • 4
  • Locked
Use the keyboard to enter two numbers m and n. Using a for loop, display an n x m rectangle made of eights. Here's an example: m=2, n=4 8888 8888
You can't complete this task, because you're not signed in.
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
BobbyGWilly
Level 6 , United States of America, United States
25 January, 18:25
Good time to use printf here...
for (int i=0; i<m; i++) {
   for (int e=0; e<n; e++) {
      System.out.printf("8");
   }
   System.out.printf("%n");
}
Hoist
Level 8 , San Diego, United States
3 October 2021, 21:40
help from www.stackoverflow.com for sure --- this is producing a nice filled rectangle -- but does not pass codegym ... just yet * Using scanner vs bufferedreader just to get started > need more ideas to finish it to pass
Hoist
Level 8 , San Diego, United States
3 October 2021, 21:52
READ the Flow of Tasks very carefully ! --- rectangle height had to be the 1st input -- which was sort of implied; And commented out / got rid of the other test junk for input data. See scanner import library/utility at the top of file. * I just dump some possible starter code (from Googling Java) into IntelliJ or VSCode and mess around with different approaches so I don't get stalled out.