Hello, I'm working on an assignment due next week and I'm having quite a bit of trouble.
The program is to ask the user for input of a double until they desire to stop. That part, I imagine will be in the Test file. The master file is to store the inputs in an array list, count how many instances of doubles there were, and then output each variable, add them all the together, find the average, the largest, and the smallest value. I know this is probably really easy, but I haven't been in Java for 2 years so I'm struggling and I need to know what I'm doing wrong if, that is I'm doing anything right at all lol.
Example of desired output:
Please enter a double value: 3.5
Another?: Y
Please enter a double value: 4.3
Another?: Y
Please enter a double value: 7.3
Another?: N
Value 1: 3.50000
Value 2: 4.30000
Value 3: 7.30000
Sum: 15.100000
Average: 5.033333
Largest: 7.300000
Smallest: 3.500000
List cleared.
---My code so far---
public class ArrayList
{
private double sum, average, large, small;
public ArrayList()
{
final int MAX_ARRAY = 15; //hold up to 15 values
double[] list = new double[ MAX_ARRAY ];
}
public Data()
{
for(int count = 1; count < list.length; count++)
}
public void process(list)
{
double sum, average, large, small;
for(int count = 1; count < list.length; count++)
sum += list[ count ];
for(int count = 1; count < list.length; count++)
average = list[ count ] / count;
for(int count = 0; count < list.lenght; count++)
if(large < list[ count ];)
{
large = list[ count ];
large = count;
}
for(int count = 0; count < list.length; count++)
if(small > list[ count ];)
{
small = list[ count ];
small = count;
}
}
public display()
{
return list;
return sum;
return average;
return large;
return small;
}
public clearData()
{
list[] = 0;
count = 0;
}
}
Any help is appreciated, thanks.