Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CalcMode{
- public static void main(String []args){
- int[][] array = new int[6][2];
- Scanner input = new Scanner(System.in);
- System.out.print("Please, insert the scores and the frequency of each score:\n");
- int i = 0;
- while (input.hasNextLine()) {
- Scanner line = new Scanner(input.nextLine());
- int x = 0;
- while (line.hasNextInt()) {
- array[i][x] = line.nextInt();
- x++;
- }
- i++;
- if ( i == 6 ) {
- break;
- }
- }
- int highest = 0;
- int mode = 0;
- for( i = 0; i < array.length ; i++ ) {
- if (array[i][1] > highest) {
- highest = array[i][1];
- mode = array[i][0];
- }
- }
- System.out.println("The mode of students score is " + mode);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement