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 CC53 (hexidecimal) to the octal equivalent
Convert CC53 (hexidecimal) to the octal equivalent
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)
Give the binary equivalent of the decimal number of 19.9 (assume fixed point, no more than...
Give the binary equivalent of the decimal number of 19.9 (assume fixed point, no more than 6 bits left and right of the decimal point(show work)
Write an application, CylinderStats, that reads the radius and height of a cylinder and prints its...
Write an application, CylinderStats, that reads the radius and height of a cylinder and prints its surface area and volume. Use the following formulas. Print the output to five decimal places. In the formulas, represents the radius and the height.Surface are 2πr(r+ h) Volume:πr2h Design and implement a class Cylinder that contains instance data that represents the cylinder’s radius and height. Define a Cylinder constructor to accept and initialize the radius and height.Include getter and setter methods for all instance...
3. Write a java method that accepts a binary number and converts it to decimal then...
3. Write a java method that accepts a binary number and converts it to decimal then display the result. For Example: (110)2 = (6)10 (2 2 *1)+ (21 *1) + (20*0) = 6 Additional task: write a method that accepts a decimal and converts it to binary. i need to solve it as soon as and i will upvote you directly
What is (567.12) octal in binary. What is(5CF.AD) hexadecimal in binary. Please show work so I...
What is (567.12) octal in binary. What is(5CF.AD) hexadecimal in binary. Please show work so I can understand how to solve thanks.
Write an application, Phone Numbers, that creates and prints a random phone number of the form...
Write an application, Phone Numbers, that creates and prints a random phone number of the form XXX-XXX-XXXX. Include the dashes in the output. The phone number has some constraints. Do not let the first three digits contain an 3 or 7 (but do not be more restrictive than that) and ensure that the second set of three digits is not greater than 825. Note that any of the digits can be zero and zeroes should be shown.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT