I'm given a table of 7 chess players, each of which have played five games of chess 0 = loss, 0.5 = tie, 1 = win. i first have to ask the user a question whether or not he/she wants to fill the arrays with random scores or not, if the user inputs y it should fill in the array with random scores if the user inputs n it should just show the originally inserted scores, additionally, i have to find out and display which people one at least 3 times... i've been sitting with this for quite some time and just don't know what to do anymore, any help would be appreciated
package dip107;
import java.util.Random;
import java.util.Scanner;
public class Md4_201rdb032 {
public static void main(String[] args) {
double A[][] = {{0.5, 0.5, 0.5, 0.5, 0.5},
{0, 1, 0, 1, 1},
{0.5, 1, 0.5, 0.5, 0},
{0, 0.5, 0, 0.5, 0},
{1, 1, 1, 1, 1},
{0, 0, 0, 0.5, 0.5},
{0, 0.5, 0, 0, 1}};
int i, j;
int loserCount, winnerCount;
String ch = "n";
System.out.println("Dev");
System.out.print("Aizpildīt masīvu ar patvaļīgām vērtībām (y/n)? ");
Scanner sc = new Scanner(System.in);
if (sc.hasNext()) {
ch = sc.next();
}
else {
System.out.println("input-output error");
sc.close();
return;
}
sc.close();
Random rnd = new Random();
if (ch.equals("Y") || ch.equals("y")) {
for (i=0; i<5; i++)
for (j=0; j<7; j++)
A[i][j] = rnd.nextInt(3)/2.0;
}
else
if (!ch.equals("N") && !ch.equals("n")) {
System.out.println("input-output error");
return;
}
for (i=0; i<5; i++) {
for (j=0; j<7; j++)
System.out.print(A[i][j] + "\t");
System.out.println();
}
System.out.println("result:");
for (i=0; i<5; i++) {
loserCount = 0;
winnerCount = 0;
for (j=0; j<7; j++) {
if (A[i][j] == 1) winnerCount++;
if (A[i][j] < 0.5) loserCount++;
}
}
}
}