parallel array concepts
Author |
Message |
bryce_21
|
Posted: Tue Apr 15, 2014 4:22 pm Post subject: parallel array concepts |
|
|
help using the parallel array concepts to reference and store the number of all "A" grades (>=90) at array index 0.........please look at the attachment below for more details....
please anyone who know java programming i need so assists....on this project i am working on
Description: |
|
Download |
Filename: |
INT 2200 PROJECT #4U(1).pdf |
Filesize: |
37.99 KB |
Downloaded: |
727 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Tue Apr 15, 2014 5:01 pm Post subject: RE:parallel array concepts |
|
|
What's the problem you're having? Have you tried anything at all?
|
|
|
|
|
|
bryce_21
|
Posted: Tue Apr 15, 2014 5:42 pm Post subject: RE:parallel array concepts |
|
|
here's my program
the i have problems with this project is creating the parallel array to reference and store the number of all A,B,C,D,F at array index0-4,
Java: |
public class project04 {
public static void main (String[] args ) {
rand_distribution ();
}
public static void rand_distribution () {
char letterGrades= 0;
Random r = new Random();
int A= 0,B= 0,C= 0,D= 0,F= 0;
int sum = 0;
int []grades = new int [100];
int [] letterGradeCounts = new int[5]; //A,B,C,D,F
for ( int i = 0; i< 100; i++ )
{
letterGradeCounts [5] = grades [i ];
grades [i ] = (int)(10 * r. nextGaussian()+ 7);
sum += grades [i ];
if (90 <= grades [i ] && grades [i ] <= 100) {
letterGrades = 'A';
A++;
} else if (80 <= grades [i ] && grades [i ] < 90) {
letterGrades= 'B';
B++;
} else if (70 <= grades [i ] && grades [i ] < 80) {
letterGrades= 'C';
C++;
} else if (60 <= grades [i ] && grades [i ] < 70) {
letterGrades= 'D';
D++;
} else if (50 <= grades [i ] && grades [i ] < 60) {
letterGrades= 'F';
F++;
}
}
Arrays. sort (grades );
for (int j= 0; j< 100; j++ )
System. out. println("Sorted Array values" + grades );
System. out. println("Minimum Value: " + grades [0]);
System. out. println("Maximum value:" + grades [99]);
}
}
|
Mod Edit:
Please wrap you code in either of the following in order to preserve whitespace (indentation) and to highlight the syntax.
code: |
[syntax="java"] ... code ... [/syntax]
[code] ... code ... [/code ]
|
|
|
|
|
|
|
Insectoid
|
Posted: Tue Apr 15, 2014 6:21 pm Post subject: RE:parallel array concepts |
|
|
code: | int A=0,B=0,C=0,D=0,F=0; |
The whole point of the array is so that you don't need these variables.
code: | char letterGrades=0; |
what's this variable for?
code: | letterGradeCounts[5] = grades[i]; |
What's the line supposed to do?
|
|
|
|
|
|
bryce_21
|
Posted: Tue Apr 15, 2014 6:30 pm Post subject: RE:parallel array concepts |
|
|
letterGradeCounts[5] = grades[i]; was suppose to reference to the array grades[] to store all the number of "A-F" at array index 0-4 using the parallel array concept
|
|
|
|
|
|
Insectoid
|
Posted: Tue Apr 15, 2014 6:44 pm Post subject: RE:parallel array concepts |
|
|
Here's a question for ya: Does letterGradeCounts[5] even exist?
|
|
|
|
|
|
Zren
|
Posted: Tue Apr 15, 2014 7:03 pm Post subject: RE:parallel array concepts |
|
|
code: | else if (50 <= grades[i] && grades[i] < 60) { |
What happens when a grade is 42?
Edit: Stop PMing me. Just post your questions in this thread so anyone can answer.
Quote: if you can help with understanding how to reference and store the number of all "A - F" at array index 0-4.
on this project that would be a blessing....please and thank you
on my project it ask me to create another array and parallel array concept to reference and store the number of all "A grades (>=90) at array index 0 ........
Edit 2:
Reread the question. It's asking you to _count_ the number of grades that fall under A, B, etc. Then store those counts in the array.
Edit 3:
Here's the basic algorithm:
code: |
Populate the grades array
Default the counters to 0
For each grade:
if grade is in the range of an 'A':
Increment the counter counting the number of A grades.
else if grade is in the range of an 'B':
Increment the counter counting the number of B grades.
else if ...
|
In this case, "Increment the counter counting the number of A grades." would be letterGradeCounts[0]++, as letterGradeCounts is representing the counters for all the grades grouped by the "letter grade". The first index (0) representing the grades that fall under A.
|
|
|
|
|
|
Tony
|
Posted: Wed Apr 16, 2014 12:33 am Post subject: RE:parallel array concepts |
|
|
bryce_21 -- please keep the discussion to this thread, instead of creating duplicate threads.
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Sponsor Sponsor
|
|
|
bryce_21
|
Posted: Wed Apr 16, 2014 11:22 am Post subject: RE:parallel array concepts |
|
|
how can i use the above algorithm with parallel array concepts to reference and store does grades
|
|
|
|
|
|
bryce_21
|
Posted: Wed Apr 16, 2014 1:14 pm Post subject: RE:parallel array concepts |
|
|
help on this java project on arrays
Write a JAVA program that (1) creates a one-dimensional array and uses a random number
generator(gaussian random numbers with a mean of 70 and a standard deviation of 10)to
populate the array with at least 100 but no more than 200 integer numbers representing exam
grades between zero(0) and 100 inclusive, (3) creates another one-dimensional array and use
the parallel array concept to reference and store the number of all "A" grades(>=90) at array
index 0, all "B" grades(80 - 89) at array index 1, all "C" grades(70 - 79) at array index 2, all "D"
grades(60 - 69) at array index 3, and all "F" grades(<60) at array index 4, (4) determines the
minimum and maximum exam grades, (5) computes the class average for the exam, and (6)
outputs the computed information in the following format:
MIDTERM EXAM RESULTS
AVERAGE: 76.00% MINIMUM: 22% MAXIMUM: 96%
A - 5
B - 7
C -12
D - 4
F - 3
Notes:
|
|
|
|
|
|
|
|