Login
Search   Moderators Wanted: If you're interested please send your portfolio to info[at]itechforums.com
Welcome to the iTechForums.
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
To register now click here.
Latest Threads
Advertisements
Forum Statistics
Threads:
Posts: 3
Members:
Number of Users Online:
Welcome to our newest member,
Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2009, 06:23 AM
Don G Don G is offline
Junior Member
 
Join Date: Feb 2009
Posts: 1
Default

Java Eclipse Parallel loops question?


Java Eclipse Parallel loops question?

Java Eclipse Parallel arrays / temp loops question?
I have to write a program using parallel arrays to answer some questions about the Chicago Bulls 1992-1993 winning season. So far, I have set up the arrays, but I'm not sure how to write the temp loops. Here is the program so far.

public class Basketball {



public static void main(String[] args) {


String [] name = {"Michael Jordan, Scottie Pippen, Horace Grant, B.J. Armstrong, Scott Williams, Stacey King"};


int [] age = {29, 27, 27, 27, 25, 24, 26};


int [] scored = {2541, 1510, 1017, 1008, 422, 408};


double [] percent = {0.495, 0.473, 0.508, 0.499, 0.466 ,0.471};


int [] attempts = {2003, 1327, 829, 151, 356, 340};


int [] assists = {428, 507, 201, 330, 68, 71};



int temp = 0;


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

{

if (age[x] < age[temp])


temp = x;

}


System.out.println("The youngest player is " +temp);


temp = 0;


for (int y =1; y<6; y++)

{

if (scored[y] > scored[temp])


temp = y;

}


System.out.println(" Had the most assists" +temp );


temp = 0;


for (int z =1; z<6; z++)

{

if (scored[z] > scored[temp])


temp = z;

}


temp = 0;


for (int w =1; w<6; w++)

{

if (scored[w] > scored[temp])


temp = w;

}


temp = 0;


for (int v =1; v<6; v++)

{

if (scored[v] > scored[temp])


temp = v;

}




}


}

I need the program to be able to answer the following questions.
1. Who is the youngest player?
2. Who had the most assists?
3. Who had the highest field goal percentage?
4. Who scored the most points?
5. Who had the most field goal attempts?
6. What is the total number of points scored for the top six players?

I need to allign the name arrays and other arrays for questions 1-5. I'm not sure how to do this. Any help would be appreciated. Before you submit a response please check if what you're suggesting will make the program work. Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2  
Old 02-10-2009, 06:23 AM
Chad O Chad O is offline
Junior Member
 
Join Date: Feb 2009
Posts: 1
Default

Please don't ask the same question twice without giving time for a response. Check your other question for further help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 02-10-2009, 06:30 AM
natlang natlang is offline
Junior Member
 
Join Date: Feb 2009
Posts: 1
Default

Instead of printing temp, you want to print name[temp].

Also, your name[] array currently has just one big string as an element. It should be split up into 6 strings separated by commas.

And the age[] array has 7 elements, one too many.

When looping through an array, you should start with index 0 instead of 1.

I might have missed something, but hopefully that gets you on the right track.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Question regarding for loops.? Jefffan24 MySQL 0 10-24-2009 01:14 PM
Java Eclipse Arrays Question 10 points for Best Answer? John U Java, Java Servlets & JSP 0 02-17-2009 11:40 PM
how to execute parallel queries in oracle using java? rahul Java, Java Servlets & JSP 0 07-27-2008 11:20 AM
how do i initialize a parallel array in java? PsycCute Java, Java Servlets & JSP 0 06-14-2008 01:16 PM
Question About JavaScript Loops? Dan H JavaScript 0 05-06-2008 08:52 PM

Your Ad Here

All times are GMT. The time now is 11:51 AM.