|
Latest Threads
Advertisements
Forum Statistics
Threads:
Posts: 3
Members:
Number of Users Online:
Welcome to our newest member, |
|
 |

02-10-2009, 06:23 AM
|
|
Junior Member
|
|
Join Date: Feb 2009
Posts: 1
|
|
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.
|

02-10-2009, 06:23 AM
|
|
Junior Member
|
|
Join Date: Feb 2009
Posts: 1
|
|
Please don't ask the same question twice without giving time for a response. Check your other question for further help.
|

02-10-2009, 06:30 AM
|
|
Junior Member
|
|
Join Date: Feb 2009
Posts: 1
|
|
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.
|
 |
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|