Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java programming error. Once I javac i am given this message. \"BuggyDriver.java

ID: 3683885 • Letter: J

Question

Java programming error. Once I javac i am given this message.

"BuggyDriver.java:81:Error: reached end of file while parsing"

HERE IS THE PROGRAM

/*

Source Name:   BuggyDriver.java
Date
Written

Revised   

Purpose: To identify and fix common syntax errors and a few
logic errors in a Java program.
*/

import java.io.*;
public class BuggyDriver
{
   public static void main(String args[]) throws IOException
   {
       Buggy app;
       app = new Buggy();
       app.appMain();
   }   
} // end of class BuggyDriver

class Buggy
{
   // Data/Field Declarations
   BufferedReader stdin;
   int firstVar, secondVar;


   /* appMain method calls for initialization, processing, output */
   public void appMain() throws IOException;
   {
       initVars();
       while(firstVar < 18)
       {
           System.out.println("Calling the calc method.");
           calc();
       }
   }  

   void initVars()
   {
       // create input object to connect to the keyboard
       stdin = new BufferedReader
           (new InputStreamReader(System.in));
          
       FirstVar = 11;
       secondVar = 22;
       thirdVar = 33;
   }  

   /* calc method calls for comparisons, calculations & detail output */
   void calc()
   {
       if(firstVar < 13)
       {
           System.out.println("firstVar is " + firstVar + " ");
           firstVar = firstVar + 1;
       }
       else
       {
           System.out.println("firstVar is 13 or greater. ");
           firstVar = firstVar + 2;
           secondVar = secondVar - 1;
           firstVar + secondVar = thirdVar;
       }
   }  
       /* reportOut method does the final output */
       void reportOut ()
       {      
           System.out.println(" FINAL REPORT");
           System.out.println("------------");
           System.out.println("firstVar is " + firstVar) ;
           System.out.println("secondVar is " + secondVar);
           System.out.println("thirdVar is " + thirdVar);
           if(firstVar < 11);
           {
               System.out.println("THIS SHOULD NOT PRINT") ;
           }
} // end of class Buggy

  

BuggyDriver.java:81: error: reached end of file while parsing I/ end of class Buggy

Explanation / Answer

Hi I have fixed all issues.

Please test it.

import java.io.*;
public class BuggyDriver
{
   public static void main(String args[]) throws IOException
   {
       Buggy app;
       app = new Buggy();
       app.appMain();
   }
} // end of class BuggyDriver

class Buggy
{
   // Data/Field Declarations
   BufferedReader stdin;
   int firstVar, secondVar,thirdVar;


   /* appMain method calls for initialization, processing, output */
   public void appMain() throws IOException
   {
       initVars();
       while(firstVar < 18)
       {
           System.out.println("Calling the calc method.");
           calc();
       }
   }

   void initVars()
   {
       // create input object to connect to the keyboard
       stdin = new BufferedReader
               (new InputStreamReader(System.in));

       firstVar = 11;
       secondVar = 22;
       thirdVar = 33;
   }

   /* calc method calls for comparisons, calculations & detail output */
   void calc()
   {
       if(firstVar < 13)
       {
           System.out.println("firstVar is " + firstVar + " ");
           firstVar = firstVar + 1;
       }
       else
       {
           System.out.println("firstVar is 13 or greater. ");
           firstVar = firstVar + 2;
           secondVar = secondVar - 1;
           thirdVar = firstVar + secondVar;
       }
   }
   /* reportOut method does the final output */
   void reportOut ()
   {
       System.out.println(" FINAL REPORT");
       System.out.println("------------");
       System.out.println("firstVar is " + firstVar) ;
       System.out.println("secondVar is " + secondVar);
       System.out.println("thirdVar is " + thirdVar);
       if(firstVar < 11);
       {
           System.out.println("THIS SHOULD NOT PRINT") ;
       }
   } // end of class Buggy
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote