Mac Java Homework - Compilation Error

mcmacmcmac

macrumors member
Original poster
Oct 2, 2007
86
0
Hey guys, when I try to compile this I get 1 error.. but i don't get it, I don't think I'm suppose to have a ; at the end of that line and when i put it, i get another error.. i'd really appreciate any help with this!

java:27: ';' expected
While (testVariable != -1)

1 error



Tool completed with exit code 1


Code:
import java.util.Scanner; // program uses class Scanner

public class Factors2
{

	public static void main(  String args[]  )

	{

		System.out.println( "Student Name: Bob\nStudent Number: 999\n\n" );

		// create Scanner to obtain input from command window
		Scanner input = new Scanner ( System.in );

		int testVariable; // variable entered by user
		int factorCounter; // factors to divide into the test variable to solve for primitive values
		double testFactor; // result of dividing the factor counter into the test variable



		// prompt for input and read integer from user
		System.out.print("Enter a positive integer number or -1 to quit:");
		testVariable = input.nextInt();


		// loop until sentinel value read from user
		While (testVariable != -1)
		{
			for (factorCounter = testVariable; factorCounter >= 0; factorCounter--)
			{
				testFactor = (testVariable / factorCounter);

				System.out.printf("%.2f, %d", testFactor, factorCounter);

			} // end for

			// prompt for input and read next grade from user
			System.out.print("Enter a poisitive integer number or -1 to quit");
			testVariable = input.nextInt();


		} // end while

		if (testVariable == -1)
		{
			System.out.println("Press any key to continue . . .");
		} // end if

	} // end main method

} // end class Factors
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.