My code is to run a java program that contains several scores in an array and print them out according to their rangescore.
this is my code:
package Assignment.Q070;
import java.io.File;
import java.util.Scanner;
public class Q070 {
public static void main(String[] args) throws Exception {
Scanner input = new Scanner(System.in);
int rangescore[] = {
76,
89,
150,
135,
200,
76,
12,
100,
150,
28,
178,
189,
167,
200,
175,
150,
87,
99,
129,
149,
176,
200,
87,
35,
157,
189
};
int score = 0;
for (int i = 0; i < rangescore.length; i++) {
score = rangescore[i];
}
while (input.hasNextLine()) {
if (score >= 0 && score <= 24)
rangescore[0]++;
else if (score >= 25 && score <= 49)
rangescore[1]++;
else if (score >= 50 && score <= 74)
rangescore[2]++;
else if (score >= 75 && score <= 99)
rangescore[3]++;
else if (score >= 100 && score <= 124)
rangescore[4]++;
else if (score >= 125 && score <= 149)
rangescore[5]++;
else if (score >= 150 && score <= 174)
rangescore[6]++;
else if (score >= 175 && score <= 200)
rangescore[7]++;
else
System.out.print("\nError occured ");
}
System.out.print(" Range Student \n");
System.out.print(" 0 - 24: \n" + rangescore[0]);
System.out.print(" 25 - 49: \n" + rangescore[1]);
System.out.print(" 50 - 74: \n" + rangescore[2]);
System.out.print(" 75 - 99: \n" + rangescore[3]);
System.out.print(" 100 - 124: \n" + rangescore[4]);
System.out.print(" 125 - 149: \n" + rangescore[5]);
System.out.print(" 150 - 174: \n" + rangescore[6]);
System.out.print(" 175 - 200: \n" + rangescore[7]);
}
}
I am using Netbeans Apache IDE 12.4 version.
when I compile my program, there is no error shows, and it shows that the compiler is running. please help me solve this problem.