'Making polynomial Evaluator and am getting an "Array required, but String found" and double found error for my for loop what am I doing wrong?

import java.util.Scanner;
import java.util.StringTokenizer;

public class newpoly {
    
    public static void main(String[] args) {
        Scanner keyboard = new Scanner(System.in);
        String poly = "";
        double x = 0.0;
        String fx = "";
        double result = 0.0;
    
        System.out.println("Please enter a polynomial:");
        poly = keyboard.nextLine();
        fx = poly.substring(5);
        System.out.println("Please enter an x value:");
        x = keyboard.nextDouble();
        StringTokenizer v = new StringTokenizer(fx," ");
            
        while(v.hasMoreTokens()) {
            String token = v.nextToken();
                
            if (token.contains("x")) {
                String coeff = token.substring(0,token.indexOf("x"));
                String deg = token.substring(token.indexOf("^") + 1);
                System.out.println(coeff);
                System.out.println("______________________");
                System.out.println(deg);  
            
                }else {
                    String coeff = token;
                    String deg = "0";
                    System.out.println(coeff);
                } 
                for (int i = 0; i < 5; i++) {
                    result += Double.parseDouble(poly[i]) * Math.pow(x, Integer.parseInt(x[i]));    
                }   
                                
        }
    }
}

Array required, but string found Array required, but double found



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source