Write a program, in Java, to convert from binary to decimal andfrom from binary to hexadecimal. Please
Fantastic news! We've Found the answer you've been seeking!
Question:
Write a program, in Java, to convert from binary to decimal andfrom from binary to hexadecimal. Please use instance variables,preferably strings. The program must do the conversion withoutusing any of the built-in functions from the Java library. Thankyou in advance.
Effectively I need the code to look like the following, except Ineed it to be done for binary to decimal/hexadecimal:
HexaDecimal to Binary conversion in Javaimport java.util.Scanner; public class Hexa_Binary { Scanner scan; int num; void getVal() { System.out.println("HexaDecimal to Binary"); scan = new Scanner(System.in); System.out.println("Enter the number :"); num = Integer.parseInt(scan.nextLine(), 16); } void convert() { String binary = Integer.toBinaryString(num); System.out.println("Binary Value is : " + binary); }} class MainClass { public static void main(String args[]) { Hexa_Binary obj = new Hexa_Binary(); obj.getVal(); obj.convert(); }}
Related Book For
Business Communication Essentials a skill based approach
ISBN: 978-0132971324
6th edition
Authors: Courtland L. Bovee, John V. Thill
Posted Date: