Advertisement
sudoaptinstallname

Untitled

Jan 29th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /*
  6. Amon Guinan
  7. Jan 2019
  8. Program reads binary and converts to decimal.
  9. */
  10. public class Six_sixtyFive {
  11. public static void main(String[] args) {
  12. Scanner input = new Scanner(System.in);
  13. System.out.print("Input Binary: ");
  14. String num_String = input.nextLine();
  15. int next_int;
  16. int dec = 0;
  17. for(int x = 0; x<num_String.length(); x++)
  18. {
  19. next_int = num_String.charAt(x);
  20. dec = dec + next_int^x;
  21. }
  22. System.out.print(dec);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement