Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help with this code

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Help with this code

    for(row = 0 ; row < size ;row++){
        result = 0;
        for (col = 0 ; col < size ; col++)
    result = matrix[row][col] +result;
    magic = result;
     
        sumRows[row]= result;
            if (sumRows[row] == magic){
        System.out.println("Row " +count +" = "+ result + " OK");}
    else
        System.out.println("Row " +count +" = "+ result + " NOT OK");
        count++;
        }

    i have this code where i prompt the user to enter a number then that number will be the size of the array i.e if the user enters 3 the size of the array will be 3x3

    then the user fills each location with ints.. then computes the sum of rows and columns

    so i have the top code i need to make the 1st sum to be the magic number so that the magic number will be compared to the other sums to determine if the square is a magic square.. help


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Help with this code

    I'm not really sure what the problem is.
    Can you please post all of your code so I can attempt to compile it? Thanks.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.