2 Replies - 225 Views - Last Post: 31 May 2013 - 02:31 AM Rate Topic: -----

#1 judd123  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 27-May 13

Compiler Error

Posted 30 May 2013 - 11:51 PM

Coder.java:22: cannot find symbol
symbol : variable runEncodeFile
location: class Coder
case 1: runEncodeFile=encodeFile;
^
Coder.java:22: cannot find symbol
symbol : variable encodeFile
location: class Coder
case 1: runEncodeFile=encodeFile;
^
Coder.java:24: cannot find symbol
symbol : variable runDecodeFile
location: class Coder
case 2: runDecodeFile=decodeFile;
^
Coder.java:24: cannot find symbol
symbol : variable decodeFile
location: class Coder
case 2: runDecodeFile=decodeFile;







import io.*;

        public class Coder
{

        public static void main (String [] args)
        {
        int processSelected;
        processSelected=ConsoleInput.readInt("Enter Process you would like to run \n 1: Encode File \n 2: Decode File \n 3: Quit Program  \n Choose Option ");

        if (processSelected != 1 || processSelected != 2 || processSelected != 3)
        {
        System.out.println("Incorrect Number Entered for option, Choose 1, 2 or 3");
        processSelected=ConsoleInput.readInt("Enter Your Choice");
        }
        else
        {
        switch (processSelected)
        {
        case 1: runEncodeFile=encodeFile;
        break;
        case 2: runDecodeFile=decodeFile;
        break;
        case 3: System.exit(0);
        }
        }
        }

        private static String encodeFile()
        {
        String qwerty;
        qwerty=("encode submodule is working");
        return qwerty;
        }

        private static String decodeFile()
        {
        String poiuy;
        poiuy=("Decode submodule is working");
        return poiuy;
        }
}




Is This A Good Question/Topic? 0
  • +

Replies To: Compiler Error

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Compiler Error

Posted 31 May 2013 - 02:18 AM

The error messages tell you what's wrong and point to exactly where the problem is. What more can we do for you?
Was This Post Helpful? 0
  • +
  • -

#3 jjh08  Icon User is offline

  • D.I.C Head

Reputation: 55
  • View blog
  • Posts: 198
  • Joined: 13-July 12

Re: Compiler Error

Posted 31 May 2013 - 02:31 AM

I just ran this in Eclipse. Oh my, the red.
You have imported a package named io. No such package exists. You probably meant
import java.io.*;

However, you are not using anything within that package based on this code so it shouldn't be declared in the first place.

This line:
processSelected=ConsoleInput.readInt("Enter Process you would like to run \n 1: Encode File \n 2: Decode File \n 3: Quit Program  \n Choose Option ");

What is ConsoleInput? That class does not exist in any of Java's standard libraries so it must be user-defined. If so, you would need to import that class in order to use the method readInt(). However it appears that you are trying to input some data so you should use Scanner in java.util

These lines:
case 1: runEncodeFile=encodeFile;
break;
case 2: runDecodeFile=decodeFile;
break;
case 3: System.exit(0);


The variable runEncodeFile is not declared so that will not work. Even if it did, you can't call the methods without the parentheses so it would look something like this
runEncodeFile = encodeFile();

Also, for case 3, the System.exit(0) is not necessary.

Overall, you may want to reconsider your design. You will want to place your code logic inside of constructors and methods and call them with main(). It is doing too much work. Hope that helps :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1