the output

problems:Code:`as for octal:`

Input Orginal Base : 8

Input a number to be converted: 278

Input a number again:

as for binary:

Input Orginal Base: 2

Input a number : 123

Input a number again:

as for hexa:

Input Orginal Base: 16

Input a number : 123g

Input a number again:

1.since its 278

the program will ask the number to be converted again

since it exceeded same goes to hexa if it goes to G it will

ask the same question again also with binary if the user inputted 1234

and he chooses 2 as his original base which is a binary base it will ask the question again.

2. and if i choose 15 as a original base therefore the F shouldnt be accepted

until it reaches 10 it goes to -1

and incase that the user inputs 15 as its orginal base and the user inputted a F43 the program will ask the user to input a new number to be converted again until the max is only C.

main code:

note:Code:`do {`

System.out.println("Enter number to convert: ");

String number = kbd.next();

kbd.nextLine();

Pattern p = Pattern.compile("[0-9a-fA-F]");

Matcher m = p.matcher(number);

if (m.find()) {

} else

do {

System.out.println("Enter number to convert Again: ");

number = kbd.next();

kbd.nextLine();

m = p.matcher(number);

} while (!m.find());

int originalBase = -2;

while (originalBase < 2 || originalBase > 16) {

System.out.println("Enter the Orginal Base: ");

originalBase = Integer.parseInt(kbd.next());

kbd.nextLine();

if (originalBase < 2) {

System.out.println("Too low");

} else if (originalBase > 16) {

System.out.println("Too high");

}

}

BigInteger n = new BigInteger(number, originalBase);

int base = -2;

while (base < 2 || base > 16) {

System.out.println("Enter base FROM 2 - 16 ONLY: ");

base = Integer.parseInt(kbd.next());

kbd.nextLine();

if (base < 2) {

System.out.println("Too low");

} else if (base > 16) {

System.out.println("Too high");

}

}

System.out.println("Result is:" + n.toString(base));

System.out.println("Do you want to try it again? [yes/no]: ");

repeatChoice = kbd.nextLine();

} while (repeatChoice.equalsIgnoreCase("yes"));

}

}

the program should ask the orginal base first

before asking the number to be converted

so it can check if the number inputted matches the original base

my problem is how can i code it out and edit my previous codes