Guess while I have a topic up...
Code
import java.io.*;
import java.util.*;
public class NumberAnalysis
{
private double low , high, avg, sum ;
private double[] numbers = new double[50];
int i = 0, count;
String file1;
public void openFile(String numberFile) throws IOException
{
File file = new File(numberFile);
Scanner in = new Scanner(file);
file1 = numberFile;
while(in.hasNext())
{
numbers[i] = in.nextDouble();
i++;
}
count = i;
}
public void setLow()
{
for(i = 0; i<10; i++)
{
if(numbers[i]<low)
low = numbers[i];
}
}
public void setHigh()
{
for(i = 0; i<10; i++)
{
if(numbers[i]>high)
high = numbers[i];
}
}
public void setAverage()
{
for(i = 0; i<10; i++)
{
sum = sum + numbers[i];
}
avg = sum/10;
}
public double getLow()
{
return low;
}
public double getHigh()
{
return high;
}
public double getAverage()
{
return avg;
}
public double getTotal()
{
return sum;
}
public double getValues()
{
return numbers[2];
}
}
it runs fine and my other file that runs can get numbers so it is saving the numbers into the array but when I try and set the high/low/average it's sticking at zero. It's pretty clear I need some practice on creating classes
