Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

java - stack

jeff
jeff 


write a program which will convert the decimal form of a positive integer to its hex form and visa-versa as requested by the user. the program should check input to ensure validity and should use a stack of characters for the decimal to hex conversion. Attachments
Tags Clarifications

Answers

JAVA Solution

joyciita23
joyciita23 



... System.out.println("Enter your desired choice:");
System.out.println("1 - DECIMAL TO HEXADECIMAL ");
System.out.println("2 - HEXADECIMAL TO DECIMAL ");
System.out.println("0 - EXIT ");

do{
System.out.print("\nEnter Choice: ");
choice=s.nextInt();

if(choice==1){
System.out.println("Enter decimal number: ");
num=s.nextInt();
System.out.println(dh.ConvertToHexadecimal(num));
}

else if(choice==2){
System.out.println("Enter hexadecimal number: ");
numS=s.next();
System.out.println(dh.ConvertFromHexadecimalToDecimal(numS));
}
}while(choice!=0);
}
}
Attachments
Screenshots
Purchase Answer