In: Computer Science
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**
/*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)
