aspose file tools*
The moose likes Beginning Java and the fly likes Array output problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array output problem" Watch "Array output problem" New topic
Author

Array output problem

Gabriel White
Ranch Hand

Joined: Mar 02, 2003
Posts: 233
Hey yall, here is another Im having problems with. Here is what I am supposed to do with this program:
1)Write a statement to declare a 20 x 30 two-dimensional array of doubles named MyArr
2)Write statements to fill out the array MyArr declared above with numbers from 0.0 to 599.0, row-by-row from top to bottom.
3)Write statements to find the sum of all elements in the array MyArr declared above.
I have it all covered but my loops only top out at 551.0 and not 599.0, what am I missing? Do I need a weapon R cold air intake system to get me over the hump? Here is the code.
Thanks yall.

[ edited to alleviate the pain of scrolling left and right -ds ]
[ March 25, 2003: Message edited by: Dirk Schreckmann ]
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

The last I looked 19 * 29 = 551.


Please ignore post, I have no idea what I am talking about.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

Yes, 19 * 29 = 551, but that sort of begs the question doesn't it? The correct formula is: (i * 30) + j, not i*j. However, it might just be easier to keep a counter and keep adding one to it.
Gabriel White
Ranch Hand

Joined: Mar 02, 2003
Posts: 233
Thanks guys I'll give it a shot. btw, I know 19*29 is 551.
Peace out
Steve
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I think he was pointing out the reason that your array "tops out at 551." Since you are calculating the values with i*j and the maximum values of i and j are 19 and 29, respectively, this means the maximum value in the array will be 19*29 or 551.


Java API Documentation
The Java Tutorial
Gabriel White
Ranch Hand

Joined: Mar 02, 2003
Posts: 233
I realize that now, thanks bro.
I guess I brain farted again.
Peace out
Steve
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Yah, I'm sure it happens to all of us. I wanted to clarify just in case ;-)
Keep coding!
Layne
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451

I guess I brain farted again.

Drinkin' them damn Lone Star longnecks again huh?
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

I was just trying to give a small hint, instead of solving your whole problem for you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array output problem
 
Similar Threads
two dimensional arrays
why does 'break' traverse one more time
Sorting a numerical Array
Getting same numbers
nested for loops, need more assignment help....