CS110 Java LAB 1


Instructor: Trish Cornez



Practice with Debugging




         The following program contains syntax errors.
    1. Select the code and copy it into a Java project.
    2. Complete the program, correct any errors, and compile the code. Execute the program.
    3. Add comments to indicate what is happening at important stages in the program.
    4. How might you optimize this program? Can the number of variables be reduced?


        public static void main(String[] args)
        }
           integer n1;
           n2;
           Int n3;
           int sum = 0;

           System.out.print("Enter n1:");
           System.out.print("Enter n2: ");
           System.out.print("Enter n3: ");

           average = n1;
           average = average + n2;
           average = average + N3;
           average / 3.0 = average ;

           System.out.println(average is "average");
        }