java - How to place data from a file with Strings and Ints into an Array / How to compare arrays? -


i'm little confused , seeking direction in how achieve goal. want read file has name of mini golf player, age, , scores 9 holes of playing. want find par each hole using age. (if it's younger player par scores higher)

my input file practice.txt following content:

jay 57 4 3 2 3 5 3 2 3 4

gloria 39 4 4 3 4 3 4 3 3 5

manny 14 5 6 4 6 5 6 4 4 6

joe 3 9 8 8 7 6 6 7 5 7

the player's age denoted second number (ex: manny 14 years old.)

i placed par score information 2d array. however, can't figure out how compare 2d array of numbers array list of strings? what's way can fix or way of thinking should have solve problem? here have far!

import java.io.file; import java.util.scanner; import java.util.list; import java.io.filenotfoundexception; import java.util.arraylist;  public class imtryinghere {  public static void main (string[] args) throws filenotfoundexception   {       int [][] agegroups =      {        {4},        {7},        {11},        {15},        {100},     };      int[][] holepars=     {       {8,8,9,7,5,7,8,5,8},       {7,7,8,6,5,6,7,5,6},       {6,5,6,5,4,5,5,4,5},       {5,4,4,4,3,4,3,3,4},       {4,3,3,3,2,3,2,3,3},    };       // read in file      file inputfile = new file ("practice.txt");     scanner golfscores = new scanner (inputfile);      // create file array of data.       arraylist<string> list = new arraylist<string>();     while (golfscores.hasnext())     {       list.add(golfscores.next());     }     system.out.println(list);    } } 

should trying convert strings ints or how can place data file int array? or should not using array data file @ all? i'm , :)

(note: i'm new java can tell please try use beginner concepts. also, haven't learned bufferedreader yet not needed , neither try catch)

edit: ideally i'm looking way place data file array has both strings , numbers.

a single array cannot contain both strings , numbers.

you have multiple arrays, 1 each names , ages, , 2d array scores.

instead of reading word @ time file read line @ time, split line onto name, age , scores.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -