Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Reading from files and parsing String and Double and assigning them into a same array

I am supposed to parse:

ABC Store

3.19

2.12

1.99

10

the following elements into String and Doubles and assign them into one array.

    while(scan.hasNextLine())
    {
        String line = scan.nextLine();
        String [] arr = new String [5];
        arr[0] = scan.nextLine();
        double num1= Double.parseDouble(arr[1]);
        double num2 = Double.parseDouble(arr[2]);
        double num3= Double.parseDouble(arr[3]);
        double num4= Double.parseDouble(arr[4]);
        System.out.println (Arrays.toString(arr));

    }

I have this so far, but this code seems not working.

Comments