Trying Pass Arrays Racesdemo Races Class Constructor Got Code Little Help Import Javaio I Q11537889

“I am trying to pass the arrays from the RacesDemo to Racesclass constructor. i got the code here. just a little help”

import java.io.*; // import filereader to read files importjava.util.StringTokenizer;

public class RacesDemo { public static void main(String[]args)throws IOException {

int participants = 5; // store number of participants

import java.io.*; // import filereader to read files
import java.util.StringTokenizer;
/**
* Write a description of class realdemo here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class RacesDemo

{
public static void main(String[] args)throws IOException
{

int participants = 5; // store number of participants
String[] customerList = new String[participants]; // array to holddata from txt file
  
int[] accnum= new int[participants]; // array to hold maccountnumbers
int [] pin= new int[participants]; // array to hold pin
double[] initbal = new double[participants]; // array to holdtinitial balance
  

FileReader freader = new FileReader(“Readme.txt”); // Class to readdata in text file

BufferedReader inputFile = new BufferedReader(freader); // Class toread each line

//R//ace4Cure rockRace = new Race4Cure();

// Read each line of data from file
for (int index = 0; index < participants; index++)
{
customerList[index] = inputFile.readLine();
}
inputFile.close(); // Closes the txt file

// Display file contents
for (int index = 0; index < customerList.length; index++)
{
// System.out.println(customerList[index]);
}

for (int index = 0; index < customerList.length; index++)
{
// StringTokenizer class to separate each line into separatevariables
StringTokenizer strTokenizer = newStringTokenizer(customerList[index], “,”);

  
accnum[index] = Integer.parseInt(strTokenizer.nextToken());
pin[index] = Integer.parseInt(strTokenizer.nextToken());
initbal[index] = Double.parseDouble(strTokenizer.nextToken());

// save total pledge amount by each person to an array
  
}

//IM TRYING TO PASS THIS TO THE Races Constructor.
Races my=new Races(int[] accnum,int[] pin,double[] initbal);
  
}
  
  
}

//below is the other class calles Races

public class Races {

public Races(int[] a,int[]p,int[] i)

for(inti=0;i<5;i++{

System.out.println(accnum[i]+pin[i]+initbal[i]);} }

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *