-2

I ran into a problem with compiling my code. I managed to fix all the compiling errors that popped up aside from a few cannot find symbols all revolving around points I receive input. For the life of me I cannot find what is causing them. I realize I'm probably overlooking something, but I have no idea what that is at this moment.

import java.util.Scanner;
import java.io.*;

public class Tester{
    public static void main(String[] args){
    Scanner input=new Scanner(new File(args[0]));

    while(input.hasNextLine()){
     char posit = input.nextChar();//Finds first character
     String compar = Character.toString(posit);
     if(compar.equals("#")){//If using manager symbol
        String firstN = input.nextString();
        String lastN = input.nextString();
        double var1 = input.nextDouble();

        Employee.Manager(firstN, lastN, var1);

     }//End if manager statement

     else if(compar.equals("*")){//If using hourly symbol
        String firstN = input.nextString();
        String lastN = input.nextString();
        double var1 = input.nextDouble();
        double var2 = input.nextDouble();

        Employee.HourlyWorker(firstN, lastN, var1, var2);

     }//End if hourly statement       
   }//End while loop
  }//End main method
}//End class

Following are my errors:

Line 14:  error: cannot find symbol 
     char posit = input.nextChar();//Finds first character                   
symbol:   method nextChar() 
location: variable input of type Scanner 

Line 17:  error: cannot find symbol 
        String firstN = input.nextString();  
symbol:   method nextString() 
location: variable input of type Scanner 

Line 18:  error: cannot find symbol 
        String lastN = input.nextString();                                 
symbol:   method nextString() 
location: variable input of type Scanner 

Line 26:  error: cannot find symbol 
        String firstN = input.nextString();                                 
symbol:   method nextString() 
location: variable input of type Scanner 

Line 27:  error: cannot find symbol 
        String lastN = input.nextString();                                 
symbol:   method nextString() 
location: variable input of type Scanner 
5 errors 
  • 3
    "Cannot find symbol" (in this context) means the method you're trying to use doesn't exist. You might want to check [the documentation](https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html). – Bernhard Barker Jan 17 '18 at 15:27
  • 2
    `Scanner` does neither feature `nextChar` nor `nextString` methods. See [API](https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html). – Mena Jan 17 '18 at 15:27
  • Thank you for showing me the documentation. For some reason, I thought I'd seen them before in code from others, but I was probably imagining things. I'll also make sure to reference that when I have problems with my code. – Andrew Kubat Jan 17 '18 at 20:29

1 Answers1

0

you need to use 'input.next().charAt(0);' instead of input.nextChar() ;

char posit = input.next().charAt(0);

Saril Sudhakaran
  • 1,109
  • 9
  • 17