Write a Java program to convert a octal number to a hexadecimal numberInput Data:Input a octal number : 100Expected Output:
Equivalent hexadecimal number: 40
import java.util.Scanner; public class Exercise27 { public static void main(String args[]) { String octal_num, hex_num; int decnum; Scanner in = new Scanner(System.in); System.out.print("Input a octal number : "); octal_num = in.nextLine(); decnum = Integer.parseInt(octal_num, 8); hex_num = Integer.toHexString(decnum); System.out.print("Equivalent hexadecimal number: "+ hex_num+"\n"); } }
Sample Output:
Input a octal number : 100 Equivalent hexadecimal number: 40
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer