I keep getting a 'illegal start of an expression' and ')' expected on a loop line for a program that counts and compare ten numbers and displays the largest. I have checked for "{}" and "()" parity, and also for ";" at the end of my statements; but the following loop line keeps giving me the error:
while( [] counter <= 10);
Here's the code:
import java.util.Scanner;
class Largest//finds largest value
{
//finds the largest integer
public void findLargest()
{
//create Scanner to input
Scanner input = new Scanner(System.in);
{
//set variables
int [] counter = new int [10]; //number of integers
int x; //integer entered when prompt
int largest; //largest integer
//initialization phase
largest = 1;//initilize loop counter
//processing phase
while([] counter <= 10);//loop 10 times
{
System.out.print("Enter next number");//prompt for next integer
for (x=1; x<=numbers.compareto; x++)
numbers[x]=scan.nextInt ();//input next integer
}
if (x == 1)
largest = numbers[1];
if (numbers[x] > largestNumber)
largest = numbers[x];
}//loop ends
System.out.printf("The largest number is %d\n", Largest);
}//end method findlargest
}//end classLargest
//Largest.java
//count program with largest displayed
public class LargestTest
{
public static void main(String[] args )
{
LargestTest myLargestTest = new LargestTest();
myLargestTest.displaylargestTest();
}//end main
}//end class LargestTest