The output is supposed to be the conversion of binary to decimal. When I run this program and input (for example) 101, it will print the answers 3 times because 101 is 3 digits. How do I fix this? I only need one answer. please help

```
    import java.util.Scanner;

    public class Bin2Dec {

public static void main (String[] args){
//Convert the input string to their decimal equivalent.
    //Open scanner for input.
        Scanner input = new Scanner(System.in);
        //Declare variable s.
        String s;

        //Prompt user to enter binary string of 0s and 1s.
        System.out.print("Enter a binary string of 0's and 1's: ");
        //Save input to s variable.
        s = input.nextLine();

        //Create a loop using the length of user input as the maximum number.
        for (int i=0;i< s.length();i++){
            try {
             System.out.println("The decimal value of the binary number "+ s +" is "+error(s));
              } catch (BinaryFormatException e) {
                System.out.println("There is an error in the entered binary string:"+e.getMessage());
              }
            }
          }

          public static int error(String parameter) throws BinaryFormatException {
            int tot = 0;
            for (int i = parameter.length(); i > 0; i--) {
              char c = parameter.charAt(i - 1);
              if (c == '1') tot += Math.pow(2, parameter.length() - i);
              else if (c != '0') throw new BinaryFormatException("'"+c+"' is not a binary digit");
            }
            return tot;
          } 
        }

```