import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class ReadCellPhones {
public static void main(String Args[]) throws IOException {
Scanner s = new Scanner(System.in);
File Input = new File("Cellphone.txt");
Scanner f = new Scanner(Input);
String[] Cells = new String[20];
Double[] Amounts = new Double[20];
Double threshold = printmenu();
int number = 0;
while (f.hasNext()) {
Cells[number] = f.next();
Amounts[number] = f.nextDouble();
number++;
}
System.out.println("NUMBER\tArmount");
for (int i = 0; i < Amounts.length; i++) {
if (Amounts[i] > threshold)// THIS IS WHERE THE NULLPOINTER
// EXCEPTION OCCURS
{
System.out.print(Cells[i] + "\t" + Amounts[i]);
}
}
}
static Double printmenu() {
Scanner s = new Scanner(System.in);
System.out.print("Enter the filename: ");
String Filename = s.nextLine();
System.out.print("Cell Bill Threshold: ");
Double threshold = s.nextDouble();
return threshold;
}
}
So what I'm trying to do is read in data from a file, store the data in 2 arrays and print out the arrays if the Amounts array values is greater then what is entered for the threshold variable. but when i try to run the program the nullpointer error pops up, any idea why?