Hey guys I just ran into some pretty interesting java problems on a different website and thought some of you might get a kick out of this. Determining on how well this goes I may post some more. So here comes problem 1.

Determine the following output with the use of data.txt

import java.io.File;
import java.util.Scanner;
import java.io.IOException;

class RecArray{
  private final static int NUM = 6;
  private int [][] myGrid = new int[NUM][NUM];
  public RecArray(){
  public void load(){
    int row, col;
    String fileName = "data2.txt";
     	Scanner inFile = new Scanner(new File(fileName));
    	for (row = 0; row < NUM; row++)
      		for (col = 0; col < NUM; col++)
        		myGrid[row][col] = inFile.nextInt();
    }catch(IOException i){
    	System.out.println("Error: " + i.getMessage());
  public int calculate(){
  	return calculate(0);
  public int calculate(int count){
    if (count >= myGrid.length){
      return 0;
      int total = 0;
      for (int i = 0; i <= count; i++){
        total += myGrid[count][i];
        total += myGrid[i][count];
      total -= myGrid[count][count];
      System.out.println("count is: " + count + " and this total is: " 
			+ total);
      return total + calculate(count + 1);

public void display(){
    int row, col;
    for (row = 0; row < NUM; row++){
      for (col =0; col < NUM; col++){
        System.out.print(myGrid[row][col] + " ");

public static void main(String[] args) {
  RecArray app = new RecArray();
  int answer = app.calculate();
  System.out.println("The final answer is: " + answer);


5 6 -4 10 -6 7
2 3 6 3 -8 2
4 -9 8 4 9 -3
7 9 2 -3 5 -7
5 -9 -4 7 6 -5
-1 3 8 -4 0 8

Okay guys get at it! Hopefully this will spark a little competitive spirit within the forum...


So answering to this thread would be just showcasing my Java skills as opposed to helping anyone ????


Is this a way of disguising your homework ??


Is this an assignment which you have copied from the NET and trying to get us to explain the code to ???

Well in the first case I do not have anytime for it and in the second case show us how much effort you put in tracing the execution path and for the third case forget about getting any help.

Works for me :)

Well assuming that this is not homework, I think that it is a good idea.

I know that most of us, including stephen84s, can do this in 30 seconds, but others might learn from it and newbies may test their skill.

Of course the OP could also add the link from which he took the code

This was the worst attempt at disguising homework I've ever seen. Lol.

I always like to give the benefit of the doubt. The OP might not go to that school, and accidentally found about that site, searched it a little and found that assignment and decided to post it.

Unlikely but possible

I always like to give the benefit of the doubt. The OP might not go to that school, and accidentally found about that site, searched it a little and found that assignment and decided to post it.

Unlikely but possible

I too was secretly wishing that this wasn't some attempt at disguising homework, but the fact that the O.P. after reading the first two responses from me and you didn't dare post again (even though I saw him as one the viewers of the thread at the bottom), gives a clue as to what he was trying to do.


  • I still hope that I am wrong.

I am the best at java... Interesting statement. Does ego help at programming? Apparently, it surely does not help at getting a homework done ;)

The name is a joke not a conceited egotistical statement of any sorts. And I'm not taking any courses right now I saved all of these worksheets from an AP Computer Science online course I found a way to access and figured some newer programmers could use problems from them to better themselves. If this was any attempt to disguise my homework and get you guys to do it, wouldn't I have included number 2? Do you guys honestly think I'd just post all the problems right in a row? You can view this post however you want I was just trying to get the community of newer programmers more involved in learning the language other than asking for help. Good job on looking up the worksheet though I figured someone would have done that.

Anyways this didn't turn out quite how I liked it as people would rather spend more time flaming and making accusations based on assumption than actually trying to LEARN. You don't even have to post your answers guys, I just thought this might assess some members' knowledge or maybe certain veterans' retainment. Oh and as to why I didn't repost, I've been too busy with work to check how this turned out. At any rate, I can guarantee that I won't be doing many more of these due to the amount of hostility. You guys obviously have some sort of obsessive compulsive disorders to go this far out of your way to denounce my attempt to actually help people. If anyone wants to know about this problem pm me because posters will just tear us apart.

-IMtheBESTatJAVA (Don't take that literally now you over-analyzing flamers!)

Liar liar pants on fire !!!

Before anybody else step into this I will said don't do it.
IMtheBESTatJAVA blaming this on the community will not work. You are fully aware of the rule We only give homework help to those who show effort. The above "pretty interesting java problems" does not include any details of what you may think is the out come of this code execution. Given your previous history (yes people keep an eye on other people posting history) and no reply to obvious accusation even though you read our replies you could step in and state your intentions, but you did not do so.

Next time do us and your self favour, provide some possible problem solution and not just copy and paste whatever from wherever assignment.

Now we can continue discussion on top if you want to provide some comments on code, otherwise we may close this post down. Your call...

excellent reply

Oh and as to why I didn't repost, I've been too busy with work to check how this turned out.

**yawn** I have seen this lame excuse from you in another unrelated thread so do not expect us to fall for it.
And by the way if you are not aware, you can figure out the online users viewing a thread, by just scrolling to the bottom of the page, which helped me figure out that you had no genuine reply to our posts and needed the extra time to manufacture this one.

I did not want to post in this thread especially after Peter's second response but just wanted to finish this argument off.

Someone close this.

+1 to that.

Well I guess someone is going to close this thread pretty soon, but just before that happens let me squeeze in my views from what I have observed in this thread. (I had read it earlier too)

Okay, IMtheBESTatJAVA, I am wanting to believe you that you did not disguise your homework and that assignment matches your becuse you got it from the net whilst you were searching for some problems, but there are somethings that make me not do so. Here are they in the chronological order:

1. When someone wants to start off a discussion on something, like in your case the assignment/problem, he almost always starts off with presenting his views and then asking others for theirs. In a way like "I think blah blah blah about this, whats your opinoin guys". These were found to be missing from your initial post.

2. You mentioned in your second post

You don't even have to post your answers guys

This again was found missing from your initial post, if you were never looking for answers in the first place and just wanted people to trigger their thought process, why not make it evident from the onset. This makes me think that initially you did want the answers, but now after the covers have been blown you want to show off how less you care for them.

3. You mention in your second post :

If this was any attempt to disguise my homework and get you guys to do it, wouldn't I have included number 2

Yeah exactly, that's the reason why you did not post the number 2, because if someone found out what you were doing, you had planned to immediately fire this rocket onto him. This was going to be your alibi.

4. As stephen84s mentions, you did not fire your response right away, even though stephen84s had made is so called allegations on you days ago, but you took time to frame your response so that it would look like you are innocent victim. If it was a truth that you were telling, more often than not we would have had an immediately reply, but you, needed time, lots of it, like the ones who have to make something up need.

Lastly as peter_budo has rightly said, if you really want us to proceed on this, and thats one way to make us believe that you are innocent on this, start off with what your answer to the assignment is first, then might be we would have a go.

This article has been dead for over six months. Start a new discussion instead.