import java.util.*;
import java.io.*;
public class DialReadings
{
public static void main(String [] args) throws FileNotFoundException
{
Scanner reader = new Scanner (new File("Data.txt"));
String candidateName = reader.nextLine();
System.out.print(candidateName + " \n");
int voterName1 = reader.nextInt();
System.out.print(voterName1 + "\n");
/*
int voterName2 = reader.nextInt();
System.out.print(voterName2+ "\n");
int voterName3 = reader.nextInt();
System.out.print(voterName3 + "\n");
int voterName4 = reader.nextInt();
System.out.print(voterName4 + "\n");
int voterName5 = reader.nextInt();
System.out.print(voterName5 + "\n");
int voterName6 = reader.nextInt();
System.out.print(voterName6 + "\n");
int voterName7 = reader.nextInt();
System.out.print(voterName7 + "\n");
int voterName8 = reader.nextInt();
System.out.print(voterName8 + "\n");
int voterName9 = reader.nextInt();
System.out.print(voterName9 + "\n");
int voterName10 = reader.nextInt();
System.out.print(voterName10 + "\n");
String canidateName2 = reader.nextLine();
System.out.print(canidateName2 + "\n");
int voterName21 = reader.nextInt();
System.out.print(voterName21 + "\n");
int voterName22 = reader.nextInt();
System.out.print(voterName22+ "\n");
int voterName23 = reader.nextInt();
System.out.print(voterName23 + "\n");
int voterName24 = reader.nextInt();
System.out.print(voterName24 + "\n");
int voterName25 = reader.nextInt();
System.out.print(voterName25 + "\n");
int voterName26 = reader.nextInt();
System.out.print(voterName26 + "\n");
int voterName27 = reader.nextInt();
System.out.print(voterName27 + "\n");
int voterName28 = reader.nextInt();
System.out.print(voterName28 + "\n");
int voterName29 = reader.nextInt();
System.out.print(voterName29 + "\n");
int voterName210 = reader.nextInt();
System.out.print(voterName210 + "\n");
*/
}
public static double mean(File file) throws FileNotFoundException
{
Scanner reader = new Scanner (new File("Data.txt"));
String voterInput = reader.nextLine();
char[] voterInputArrayChar = voterInput.toCharArray();
int number = Integer.parseInt(new String(voterInputArrayChar));
int sum=0;
for (int index=0; index < voterInputArray.length; ++index)
{
sum += voterInputArray[index];
}
double average = sum / (double) voterInputArray.length;
System.out.print(voterName1);
return 0;
}
}
What I am trying to do is get the voter results into an integer array so I can find the mean, median, mode, minimum, and maximum. I know how to find the functions, I am just having trouble creating the arrays from strings

New Topic/Question
Reply



MultiQuote





|