-5

Why am I getting this error? I've tried changing many aspects of the code, but could not figure out the error. Thank you!

import java.util.*;


public class Problem1
{
    public static void main(String[] args)
    {
        int ogarank = 177;
        int ogbrank = 129;
        int ogcrank = 11;
        int newarank = 0;
        int newbrank = 0;
        int newcrank = 0;
        int input = 0;
        Scanner scan = new Scanner(System.in);

        System.out.println("Enter Your Number");
        input = scan.nextInt();

        input = input % 100;
        newcrank = separate(input, newcrank);
        input = input % 100;
        newbrank = separate(input, newbrank);
        input = input % 100;
        newarank = separate(input, newarank);

    }

    public static int separate(int input, int rank)
    {
        rank = input;
        return rank;
    }

    public static int convert(int ogrank)
    {
            int digit1;
            int digit2;
            String convert;
            digit1 = ogrank / 10;
            digit1 = digit1 * 16;
            digit2 = ogrank % 10;
            digit2 = digit2 * 1;
            convert = ("" + digit1 + "" + digit2 + "");
            ogrank = convert.parseInt();
    }

error: cannot find symbol

        ogrank = convert.parseInt();
                        ^

symbol: method parseInt()

location: variable convert of type String

Icy
  • 17
  • 4
  • 5
    It's probably because [String](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html) doesn't have a `parseInt()` method. – resueman Dec 07 '15 at 14:12

2 Answers2

4

The method is Integer.parseInt()

convert is a String type variable and doesn't have parseInt() method

Ramanlfc
  • 8,283
  • 1
  • 18
  • 24
  • Thank you I tried that earlier but it wasn't working. It's working now though, so thanks! – Icy Dec 07 '15 at 14:15
2

Change the method should have a String param like this:

 ogrank = convert.parseInt();

To:

  ogrank = Integer.parseInt("String to parse");

Description: This method is used to get the primitive data type of a certain String. parseXxx() is a static method and can have one argument or two.

Syntax: All the variant of this method are given below:

 static int parseInt(String s)
 static int parseInt(String s, int radix)

Parameters: Here is the detail of parameters:

s -- This is a string representation of decimal.

radix -- This would be used to convert String s into integer.

Abdelhak
  • 8,299
  • 4
  • 22
  • 36