Java refuses to run a program with a mistake in it; the compiler reports each one with a line number and a message. The three you will see most: ';' expected (a statement is missing its semicolon), cannot find symbol (a name is misspelled or not declared, and the message names the symbol), and incompatible types (a value of one type was put where another was needed, such as text into an int).
Read the first message first: one mistake often causes several messages, and fixing the first one clears the rest. The line number points at where the compiler noticed, which is usually the line itself or the one before.
int count = "three"; // incompatible types: String cannot be converted to int
System.out.println(cont); // cannot find symbol: variable contYour task
The starter has three mistakes. Fix them so the program compiles and prints 3 apples cost 4.5.
Hint 1
Line 3 needs a semicolon. Line 4 puts text into a double: 1.5 without quotes is a number.
Hint 2
Line 5 uses prize, which does not exist; the variable is price.
Show the solution
public class Main {
public static void main(String[] args) {
int count = 3;
double price = 1.5;
System.out.println(count + " apples cost " + count * price);
}
}