0

```
import java.text.*;
import java.io.*;
public class Assignment9
{
public static double findMin(double[] numbers, int startIndex, int endIndex)
{
if (startIndex == endIndex) return numbers[startIndex];
else
{
double prevMin = findMin(numbers, startIndex, endIndex-1);
if (prevMin>numbers[endIndex])
return numbers[endIndex];
else
return prevMin;
}
}
public static double computePositiveSum(double[] numbers, int startIndex, int endIndex)
{
if (startIndex == endIndex && startIndex>0) return numbers[startIndex];
else
{
double prevSum = computePositiveSum(numbers, startIndex, endIndex-1);
if (0<numbers[endIndex])
return numbers[endIndex]+prevSum;
else
return prevSum;
}
}
public static double computeSumAtOdd(double[] numbers, int startIndex, int endIndex)
{
if (startIndex == endIndex) return 0;
else
{
double prevSum = computeSumAtOdd(numbers, startIndex, endIndex-1);
if (0 != numbers[endIndex]%2)
return numbers[endIndex]+prevSum;
else
return prevSum;
}
}
public static int countNegative(double[] numbers, int startIndex, int endIndex)
{
if (startIndex == endIndex && startIndex>0) return 0;
else
{
double Count = countNegative(numbers, startIndex, endIndex-1);
if (0>numbers[endIndex])
return (int)Count++;
else
return (int)Count;
}
}
public static void main (String[] args)
{
try {
BufferedReader in = new BufferedReader(new FileReader(filename));
double a[] = new double[100];
int b=0;
while((a[b] = in.readArray()) != null && in.readDouble() !=0) { // Read line, check for end-of-file
a[b] = in.readArray(); // Print the line
}
in.close(); // Always close a stream when you are done with it
}
catch (IOException e) {
system.out.println("File Not Found");
}
system.out.println("The minimum number is" + findMin(a, 0, a.getLength()));
system.out.println("The sum of the positive numbers is" + computePositiveSum(a, 0, a.getLength()));
system.out.println("The sum of the numbers at odd indexes is" + computeSumAtOdd(a, 0, a.getLength()));
system.out.println("The total count of negative numbers is" + countNegative(a, 0, a.getLength()));
}
}
```

This is just the base of what I have. Im having a lot of trouble when it gets to writing the array from the input file.

*Edited 3 Years Ago by mike_2000_17*: Fixed formatting