/*
DriverBuggy.java
Source Name:    DriverBuggy.java
Date Written:   12/27/06
Written By:     Annette Lege
Revised By:     

Purpose:  To identify and fix common syntax errors and one
logic error in a Java program.
*/
import java.io.*;
public class DriverBuggy
{
    public static void main(String args[]) throws IOException
    {
        Buggy app;
        app = new Buggy();
        app.appMain();
    }   // end of main()
}  // end of class Driver

class Buggy
{
    /* Instance Data Declarations */
    BufferedReader stdin;   // define stdin
    int firstVar, secondVar, thirdVar;
    /* appMain method calls for initialization, processing, output */
    public void appMain() throws IOException;
    {
        stdin = new BufferedReader
                (new InputStreamReader(System.in));
                // create input string object
        FirstVar = 11;
        secondVar = 22;
        thirdVar = 33;
        while(firstVar < 18)
        {
            System.out.println("Calling the calc method.");
            calc();
        }
    }   // end of appMain()

    /* calc method calls for comparisons, calculations & detail output */
    void calc()
    {
        if(firstVar < 13)
        {
            System.out.println("firstVar is " + firstVar +  \n");
            firstVar = firstVar + 1;
        }
        else
        {
            [COLOR="Red"]System.out.println("firstVar is 13" or greater. n);[/COLOR]
            firstVar = firstVar + 2;
            secondVar = secondVar - 1;
            firstVar + secondVar = thirdVar;
        }
    }   // end of calc()

    /* reportOut method does the final output /*
    void reportOut()
    {
        System.out.println("\nFINAL 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

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Can someone Please help me find whats wrong with this? Its Higlighted in red and the erroe mssg when i try to copile is
55: ')' expected
can someone help me fix it?

A literal String, such as that, has a quote at the front and at the end. I assume that the entire contents betweens the parens should be a literal String, right? So why is the second quote (which ends the String literal) in the middle of it?

Hi, this is sugarskull
and you just responded to my problem and you put that i needed to check the quotes but what should i put them on and why does my error on clem say ')' expected?
System.out.println("firstVar is 13" or greater. \n);
if you can please help me i will appreciate it!!!
Thanks Sugarskull

I gave you another hint. Have you even tried to change anything yet? I am not going to give you the answer. I will give a third hint, and say that, in that statement, as soon as the String literal ends, the compiler expects the closing paren. Where, in that statement, does your String literal end, and where is your closing paren? Where should the String literal end?

No, really?

And do you actually want an "n" after the period, or did you mean "\n" for a newline (which is also redundant since println adds a newline anyway)?

Aside from the fact that it is counter productive to simply spew out the answer (the student learns nothing that way), the question has already been answered (here also if the OP was willing to use that thing between its ears) in a cross-posted thread, since the OP wasn't willing to use it.

This article has been dead for over six months. Start a new discussion instead.