The major issue I am having right now is my client class cannot run/compile, I tried different methods to fix it from calling it from overload constructor and setScores but neither work.
Scoresclient.java:16: error: cannot find symbol
myScores.setScores();
^
symbol: method setScores()
location: variable myScores of type Scanner
Scoresclient.java:18: error: cannot find symbol
System.out.println("The average score is: " + myScores.average() );
^
symbol: method average()
location: variable myScores of type Scanner
Scoresclient.java:20: error: cannot find symbol
System.out.println("The highest overall score is: " + myScores.highestscores() );
^
symbol: method highestscores()
location: variable myScores of type Scanner
Scoresclient.java:22: error: cannot find symbol
System.out.println("The lowest overall score is: " + myScores.lowestscores() );
^
symbol: method lowestscores()
location: variable myScores of type Scanner
4 errors
This is my service class
/**
* Java Car Service class
* @author blake
* 2/20/2012
*/
import java.util.Scanner;
import java.io.*;
public class Scores
{
private final int MAX=20;
private int[] scores = new int[MAX];
private int inUse = 0;
public Scores()
{
}
public Scores(String File) throws IOException
{
File myfile = new File("myfile.dat");
Scanner inputFile = new Scanner(myfile);
inUse =0;
while (inputFile.hasNext() && inUse < scores.length)
{
scores[inUse] = inputFile.nextInt();
inUse++;
}
}*/
public static void setScores() throws IOException
{
File myfile = new File("myfile.dat");
Scanner inputFile = new Scanner(myfile);
inUse =0;
while (inputFile.hasNext() && inUse < scores.length)
{
scores[inUse] = inputFile.nextInt();
inUse++;
}
}
public String toString()
{
String result = "";
result = scores[0] + "/t" + scores[1] + "/t" + scores[2] + "/t" + scores[3] + "/t" + scores[4] + "/t" + scores[5] + "/t" + scores[6] + "/t" + scores[7] + "/t" + scores[8] + "/t" + scores[9] + "/t" + scores[10] + "/t" + scores[11] + "/t" + scores[12] + "/t" + scores[13] + "/t" + scores[14] + "/t" + scores[15] + "/t" + scores[16] + "/t" + scores[17] + "/t" + scores[18] + "/t" + scores[19];
for (int i = 0; i < scores.length; i++)
result += scores[i] + "\t";
return result;
}
public int averages()
{
int avg;
avg = scores[1] + scores[2] + scores[3] + scores[4] + scores[5] + scores[6] + scores[7] + scores[8] + scores[9] + scores[10] + scores[11] + scores[12] + scores[13] + scores[14] + scores[15] + scores[16] + scores[17] + scores[18] + scores[19] + scores[20];
for (int i = 0; i < scores.length; i++)
avg += scores[i];
return avg;
}
public int lowestscores()
{
int smallest = Integer.MAX_VALUE;
for (int i = 0; i < scores.length; i++)
if (scores[i] < smallest)
smallest = scores[i];
return smallest;
}
public int highestscores()
{
int highest = -Integer.MAX_VALUE;
for (int i = 0; i < scores.length; i++)
if (scores[i] > highest)
highest = scores[i];
return highest;
}
}
This is my client class
/**
* Java Car Service class
* @author blake
* 2/2
**/
import java.util.Scanner;
import java.io.*;
public class Scoresclient
{
public static void main(String[] args) throws IOException
{
Scanner myScores = new Scanner(System.in);
myScores.setScores();
System.out.println("The average score is: " + myScores.average() );
System.out.println("The highest overall score is: " + myScores.highestscores() );
System.out.println("The lowest overall score is: " + myScores.lowestscores() );
}
}
It should be working but just getting it to accept the set method but it's not for some reason.