import java.util.Scanner;
public class DecimalMenu{
public static void main(String[]args){
Scanner scan = new Scanner(System.in);
int num1;
String decision;
System.out.println("DECIMAL MENU");
System.out.println("[1]Decimal to Binary");
System.out.println("[2]Decimal to Octal ");
System.out.println("[3]Decimal to Hexadecimal");
System.out.println("[4]Back to Main Menu");
Scanner myScanner=new Scanner(System.in);
System.out.println("Enter Your Choice: ");
num1=scan.nextInt();
boolean yn = true;
while(yn)
{
if(num1==1){
System.out.print("Enter a Decimal number : ");
String decimal=myScanner.nextLine();
int num=Integer.parseInt(decimal,10);
String binary=Integer.toBinaryString(num);
System.out.println("Binary value is : "+binary);
}
if(num1==2){
System.out.print("Enter a Decimal number : ");
String decimal=myScanner.nextLine();
int num=Integer.parseInt(decimal,10);
String octal=Integer.toOctalString(num);
System.out.println("Octal value is : "+octal);
}
if(num1==3){
System.out.print("Enter a Decimal number : ");
String decimal=myScanner.nextLine();
int num=Integer.parseInt(decimal,10);
String hexa=Integer.toHexString(num);
System.out.println("Hexadecimal value is : "+hexa);
}
if(num1==4){
}
System.out.println("INPUT ANOTHER [Y/N]: ");
decision = myScanner.nextLine();
switch(decision)
{
case "Y":
yn = true;
break;
}
switch(decision)
{
case "N":
yn = true;
break;
}
}
}
}