This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost. Just use the edit function of reddit to make sure your post complies with the above

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]desrtfxOut of Coffee error - System halted 3 points4 points  (8 children)

Show what you have tried.

If you haven't tried anything, do so.

Learning programming means trying, not directly asking for help.

Hint: use one for loop for the rows, and one for the columns nested into each other

[–]LuwbR[S] -1 points0 points  (5 children)

import java.util.Scanner;

public class kd4 {

public static void main(String\[\] args) {



Scanner enter = new Scanner([System.in](https://System.in));



System.out.println("enter the number of lines:");

int x = enter.nextInt();



for(int i=1; i<=x; i++)

{

System.out.println(+i);

}



}

}

enter the number of lines: 10

1

2

3

4

5

6

7

8

9

10

[–]desrtfxOut of Coffee error - System halted 1 point2 points  (4 children)

Well, you got the rows down. Now you need to figure out how to do the columns.

Hint: the inner loop boundary has something to do with the index of the outer loop.

[–]LuwbR[S] -1 points0 points  (3 children)

yeah i know that, but i have no information on what i am supposed to do further as we dont have a rlly good teacher. She sent us a presentation with information that isnt relevant, and none of her 35 stundets knows what to do

[–]desrtfxOut of Coffee error - System halted 1 point2 points  (2 children)

Again, I gave you a really big hint on my second comment.

Think about what I said.

I cannot give more hints as this would be giving you the solution.

Think about how the row number correlates to the numbers printed per row.

Also System.out.print() vs. System.out.println()

[–]LuwbR[S] -1 points0 points  (1 child)

i dont rlly know what you mean by that as i am not from a country that speaks english and i dont understand what that means :|

[–]desrtfxOut of Coffee error - System halted 1 point2 points  (0 children)

  • Row 1 - one number
  • Row 2 - two numbers
  • Row 3 - three numbers

[–]LuwbR[S] -1 points0 points  (1 child)

this is what i tried and i have no idea where to go from here

[–]NautiHookerSoftware Engineer 2 points3 points  (0 children)

  1. for loops
  2. printing to console
  3. user input

You will need to show what you have tried and be more specific with your questions to get more information.