Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-01-2007, 03:04 AM
Senior Member
 
Join Date: Jun 2007
Posts: 114
Albert is on a distinguished road
array problem
Hi, basically i have a 2D array 6x8 which holds integers i need to get a total for each row - can anyone help please??!!!?

Thank you

Albert
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-01-2007, 03:08 AM
Member
 
Join Date: Jun 2007
Posts: 92
Marcus is on a distinguished road
A total of what for which row? I'm assuming you want to add up all of the integers in the first row...then the total of all the integers in the second, etc.

First how would you do this on paper? Write out your algorithm and then try and translate it into java.

For a hint, here is some code that will print everything in your 2d array.

Code:
//assume foo is an int [][] array initilized earlier. for(int i=0;i<array.length;i++) { System.out.println("Printing the data in row "+i); for(int j=0;j<array[i].length;j++) { System.out.println("Value at array["+i+"]["+j+"] is "+array[i][j]); } System.out.println("moving to next row"); }
Marcus
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-01-2007, 03:13 AM
Senior Member
 
Join Date: Jun 2007
Posts: 114
Albert is on a distinguished road
This is what i want to do, in pseudo code:

for each row i in the 2d array // that is for each student
set the total for the ith student to be 0
for each column j in the row // that is for each mark for the ith student
add the mark stored at row i column j to the total for the ith student // something like total += marks[i][j]
end for // where marks is the 2d array
output the total for the ith student
calculate and output the grade for the ith student
end for

I just cant put it in java.
Thanks.

Albert
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
array problem oceansdepth New To Java 3 04-05-2008 04:25 AM
Array problem.. help needed please! SCS17 New To Java 3 03-07-2008 12:30 AM
Array List Problem khamuruddeen New To Java 1 12-22-2007 10:10 AM
array problem wats New To Java 1 12-12-2007 09:08 AM
Problem with array Copy coco New To Java 1 08-07-2007 09:46 AM


All times are GMT +3. The time now is 04:51 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org