Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- /*
- Amon Guinan
- Jan 2019
- Program reads binary and converts to decimal.
- */
- public class Six_sixtyFive {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Input Binary: ");
- String num_String = input.nextLine();
- int next_int;
- int dec = 0;
- for(int x = 0; x<num_String.length(); x++)
- {
- next_int = num_String.charAt(x);
- dec = dec + next_int^x;
- }
- System.out.print(dec);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement