Question

In: Computer Science

Write an application that prints a table of the binary and octal equivalent of the decimal...

Write an application that prints a table of the binary and octal equivalent of the decimal numbers in the range 1 through 256.

**Write in JAVA**

Solutions

Expert Solution


/*Java program that displays a table that shows octal and Hexa equivalent of decimal numbers from 1 to 256.*/
//Table.java

public class Table
{
   public static void main(String[] args)
   {
       //declare variables
       int start;
       int end = 256;
       //print heading
       System.out.printf("%-10s %-10s %-10s\n",
               "Decimal" ,"Octal","Hexa-decimal");
       /*Loop start from 1 to 256 with an increment of start by 1*/
       for (start = 1; start <=end; start++)
       {
           /*%d is a format specifier for decimal to print decimal value */
           /*%o is a format specifier for octal to print octal number of decimal value*/
           /*%x is a format specifier for hexa to print hexa decimal value of decimal */
           System.out.printf("%-17d %-10o %-10x\n",start,start,start);
       }//end of for loop
   } //end of the main method
} //end of the class,Tabel
------------------------------------------------------------------------------------------------------

Sample output screenshot:

...

...

...(continues)


Related Solutions

Any integer can be represented in binary, octal, decimal, and hexadecimal. What are the limits on...
Any integer can be represented in binary, octal, decimal, and hexadecimal. What are the limits on representing integers using unary or only having the 1 digit?
Convert the following decimal number into (a) binary and (b) Octal (SHOW ALL STEPS) 205.75
Convert the following decimal number into (a) binary and (b) Octal (SHOW ALL STEPS) 205.75
convert the binary number(base 2) To Octal (base 8) to decimal (base 10) a. 101 b....
convert the binary number(base 2) To Octal (base 8) to decimal (base 10) a. 101 b. 1001 c. 101010 d.1101101 convert the number to the other base a. 253 base 10 to base 8 b. 98 base 10 to base 3 C. 1340 base 10 to base 16 D. AB Base 16 to base 8 E. 111010 base 2 to base 16 F. 1010101 base 2 to base 6 g. 69 base 10 to base 2 h . 1023 base...
Convert CC53 (hexidecimal) to the octal equivalent
Convert CC53 (hexidecimal) to the octal equivalent
a)The decimal equivalent of the signed 2’s complement 8-bit binary number 11010101B is ______________. b)The decimal...
a)The decimal equivalent of the signed 2’s complement 8-bit binary number 11010101B is ______________. b)The decimal equivalent of the unsigned 8-bit hex number 0B4H is ______________. c)The value of the expression ‘H’ – ‘B’ is less than / equal to / greater than that of the expression ‘L’ – ‘C’. d)If the .data segment contains declarations                         A    BYTE      2 DUP (‘a’), ‘+’ B    BYTE      3 DUP (‘b’), 0 C    BYTE      4 DUP (‘c’), ‘–’ D    BYTE     ...
THE FOLLOWING QUESTION IS FOR C PROGRAMMING LANGUAGE Printing the decimal equivalent of a binary number....
THE FOLLOWING QUESTION IS FOR C PROGRAMMING LANGUAGE Printing the decimal equivalent of a binary number. Write a program that accepts an integer (5 digits or fewer) containing only 0s and 1s (i.e., binary) and prints out its decimal equivalent using the remainder and division operator to select the "binary" digits one at a time. Make sure your input is tested for multiple options: incorrect characters, too many, too few, etc. I need help making this program. No loops, if...
Write a Java program to convert decimal (integer) numbers into their octal number (integer) equivalents. The...
Write a Java program to convert decimal (integer) numbers into their octal number (integer) equivalents. The input to the program will be a single non-negative integer number. If the number is less than or equal to 2097151, convert the number to its octal equivalent. If the number is larger than 2097151, output the phrase “UNABLE TO CONVERT” and quit the program. The output of your program will always be a 7-digit octal number with no spaces between any of the...
Write a Java program to convert decimal (integer) numbers into their octal number (integer) equivalents. The...
Write a Java program to convert decimal (integer) numbers into their octal number (integer) equivalents. The input to the program will be a single non-negative integer number. If the number is less than or equal to 2097151, convert the number to its octal equivalent. If the number is larger than 2097151, output the phrase “UNABLE TO CONVERT” and quit the program. The output of your program will always be a 7-digit octal number with no spaces between any of the...
1. Give the binary equivalent of the decimal number of 11.77 (assume fixed point, no more...
1. Give the binary equivalent of the decimal number of 11.77 (assume fixed point, no more than 6 bits left and right of the decimal point)
Give the binary equivalent of the decimal number of 11.77 (assume fixed point, no more than...
Give the binary equivalent of the decimal number of 11.77 (assume fixed point, no more than 6 bits left and right of the decimal point)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT