Convert from string to double
Okay so im tring to convert a string to a double, but i keep geting a error saying: incompadible types found double but expected java.lang.string
i already tried switching things around but i cant get it to work.
this is the peice of code that im useing:
Code:
import java.util.Scanner;
import java.io.*;
public class Ice_Cream_Menu
{
public static void main(String args[]) throws IOException
{
System.out.print("\f");
String X = "";
String filename;
filename = "Prices.txt";
File file = new File(filename);
Scanner inputFile = new Scanner(file);
Scanner keyboard = new Scanner(System.in);
final int total = 30;
double prices[] = new double[total];
String product[] = new String[total];
for(int r=0; r<total; r++)
{
product[r] = inputFile.nextLine();
X = inputFile.nextLine();
product[r] = Double.parseDouble(X); // This is were im haveing the error.
}
inputFile.close();
This is the piece that i keep geting the error:
Code:
for(int r=0; r<total; r++)
{
product[r] = inputFile.nextLine();
X = inputFile.nextLine();
product[r] = Double.parseDouble(X); // This is were im haveing the error.
}