Is the following Code correct, for calculating Decimal to Triskaidecimal and Triskaidecimal to Decimal, I hope this code is not right

import java.util.Scanner;
public class converter
{
    /* 1) Decimal To Triskaidecimal
        2) Triskaidecimal To Decimal
        3)Exit.
    */
        public static void main(String ar[])
        {
            int a, b;
            String s;
            System.out.println("Please Select:\n1)Decimal To Triskaidecimal.\n2)Tridecimal To Decimal.\n3)Exit.");
            Scanner input = new Scanner(System.in);
            s = input.nextLine();
            System.out.println("You have Selected:" +s);
            switch(s)
            {
                case "1":
                System.out.println("Decimal To Triskaidecimal Conversion:");
                Scanner ip_Dec2Tri = new Scanner(System.in);
                //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                System.out.println("Please Enter A Decimal Number To Convert to Triskaidecimal Number:");
                a = ip_Dec2Tri.nextInt();
                //String Dec_Hex = br.readLine();
                int triskaidecimal = (a%13);
                if (triskaidecimal==10)
                {
                    System.out.println("The Decimal To Triskaidecimal is : A");
                }
                else if (triskaidecimal==11)
                {
                    System.out.println("The Decimal To TriskaiDecimal is : B");
                }
                else if (triskaidecimal ==12)
                {
                    System.out.println("The Decimal To TriskaiDecimal is : C");
                }
                else
                {
                    System.out.println("The Decimal To Triskaidecimal is :"+triskaidecimal);
                }

                break;
                case "2":
                System.out.println("Triskaidecimal To Decimal Conversion:");
                System.out.println("Please Enter a Triskaidecimal Number to Convert it into Decimal:");
                Scanner ip_Tri2Dec = new Scanner(System.in);
                b = ip_Tri2Dec.nextInt();
                int decimal = (b*13);
                System.out.println("The Tridecimal To Decimal is : " +decimal);
                break;
                case "3":
                System.out.println("System is Quitting!!!\nThank you for using the converter\n");
                System.exit(0);
                default:
                System.out.println("Please Provide the Correct Input\nTry again!");
                System.exit(1);
            }//end of switch s



        }
}

@JamesCherrill I'd tested it, it only works for numbers, say for example if I want to convert a decimal to triskaideciman(base13) it works good for only numbers, say for example I want to convert 13A to decimal it is giving me an error message

You read the input for that as an int, and ints do not contain As Bs or Cs, so you get an error. You have to read that input as a String and deal with each character in turn - basically the reverse of the code you have for int -> 13.

ps Your code for int to base 13 doesn't seem to have a any logic for values >= 13

@JamesCherrill
How to define a logic for converting a decimal number into triskaidecimal ? I've been looking in google but can't find it .

This article has been dead for over six months. Start a new discussion instead.