rendered paste body/**
* @(#)Text1.java
*
*
* @author
* @version 1.00 2011/10/11
*/
import java.util.Scanner;
public class Text1 {
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
int enteredBinary;
System.out.print("Enter your four digit binary number: ");
enteredBinary = input.nextInt();
int count = 1;
int updatedBinary = 0;
int firstDigit = 0;
int secondDigit = 0;
int thirdDigit = 0;
int fourthDigit = 0;
int yourTotal = 0;
while ( count <= 4 ) {
if (count == 1) {
firstDigit = enteredBinary % 10;
updatedBinary = enteredBinary / 10;
}
if (count == 2) {
secondDigit = updatedBinary % 10;
updatedBinary = updatedBinary / 10;
}
if (count == 3) {
thirdDigit = updatedBinary % 10;
updatedBinary = updatedBinary / 10;
}
if (count == 4) {
fourthDigit = updatedBinary % 10;
}
count ++;
}
yourTotal = (fourthDigit * 8)+ (thirdDigit * 4) + (secondDigit *2)+ (firstDigit * 1);
System.out.println("Your binary conversion is: " + yourTotal);
}
}