-2
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
​
public class Solution {
​
    static long maximumProgramValue(int n) {
        long x=0l,y=0l;
        long count=0l;
        while(n!=0) {
            String s=scanner.nextLine();
            if(s.next().equals("add")) {
                y=s.nextLong();
                x=x+y;
            } else {
                y=s.nextLong();
            }
            if(count < x)
            count=x;
            n--;
        }
        return count ;
    }
    ​
    private static final Scanner scanner = new Scanner(System.in);
    ​
    public static void main(String[] args) throws IOException {
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
        int n = scanner.nextInt();
        scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])*");
        long result = maximumProgramValue(n);
        bufferedWriter.write(String.valueOf(result));
        bufferedWriter.newLine();
        bufferedWriter.close();
        scanner.close();
    }
}

​ I am getting this error please help

Solution.java:21: error: cannot find symbol
            if(s.next().equals("add"))
                ^
  symbol:   method next()
  location: variable s of type String
Solution.java:23: error: cannot find symbol
                y=s.nextLong();
                   ^
  symbol:   method nextLong()
  location: variable s of type String
Solution.java:28: error: cannot find symbol
              y=s.nextLong();   
                 ^
  symbol:   method nextLong()
  location: variable s of type String
3 errors
Exit Status
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
rs dwd
  • 1
  • 4
  • 1
    Please look at [What does a “Cannot find symbol” compilation error mean?](http://stackoverflow.com/questions/25706216/what-does-a-cannot-find-symbol-compilation-error-mean) – Hovercraft Full Of Eels Apr 21 '18 at 03:19

1 Answers1

0

Your

 if(s.next().equals("add"))

should be

 if("add".equals(s))

s is of type String already. There's no use of next() method call on it.

You should convert String to long as follows

y = Long.parseLong(s); 
Shanu Gupta
  • 3,699
  • 2
  • 19
  • 29