Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import static java.lang.System.out;
- public class DecimalEquivalents {
- public static void main(String[] args) {
- new DecimalEquivalents().binaryCounter();
- }//end main()
- public void binaryCounter() {
- //count 0-100 in Binary:
- for(byte i = 0b00; i <= 0b1100100; i++) {
- try {
- Thread.sleep(250);
- } catch(InterruptedException ie) {
- out.println("oops! something went wrong !");
- out.println(ie.getMessage());
- }//end try/catch
- out.println("Nums Represented in Binary: " + Integer.toBinaryString(i));
- out.println("Decimal equivalent: \t " + i);
- out.println("Octal equivalent: \t " + Integer.toOctalString(i));
- out.println("Hexadecimal equiv: \t " + Integer.toHexString(i));
- out.println();
- }//end 4Loop
- }//end binaryCounter()
- }//end class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement