In Java statements are semi-colon terminated. Then
price=
name= " ";
is parsed as price = (name = " ")
. However, a String
(type/result of the name assignment expression) is incompatible with a double
(the type of the price variable) as they are "incompatible types".
So first step is to fix how the code is parsed
price= <put something useful here>;
name= " ";
While this will "fix" the immediate type error, the program will still not compile (due to unassigned local variables and incorrect method names) and, if it did compile, would not produce the correct results when more than one phone number is to be entered - keep reading.
Now, as far as the overall program: don't assign these "dummy values" and don't use the variables before they have meaningful values.
Consider this:
Scanner scan = new Scanner(System.in);
for (int counter = 0; counter < 1; counter++)
{
// We don't need to assign defaults because these
// variables will be assigned useful values before
// they are used.
double price;
String name;
// (other variables removed for simplicity)
System.out.println("Enter price: ");
// Java is case-sensitive, make sure to use correct case.
// The original "nextdouble" was incorrect.
price = scan.nextDouble();
System.out.println("Enter name: ");
name = scan.nextLine();
// NOW use variables - AFTER they have useful values
Phone phone = new Phone (.., .., price, name, .., ..);
// Add new phone entry each loop,
// not once at the end of all (1) loops.
phoneList.add(phone);
}