Итак, я работаю над своей домашней работой для своего класса java. Я пытаюсь закодировать простую программу, которая преобразует 4-байтовое двоичное число в десятичное. Теперь, я признаю, что я использовал некоторые строки, которые я нашел в поисках. Итак, я не совсем уверен, что происходит с моим кодом. Мой источник ниже.ошибка: достигнут конец файла при разборе - java
import java.util.Scanner;
public class B2Dconversion
{
public static void main (String [] args)
{
System.out.println("Hello, I am so glad you stopped by my little place I call home.");
System.out.println("I have been told I have many talents, but the one that I can do for you now.");
System.out.println("What I would like you to do is enter a 4-byte binary number and I will convert it for you into decimal.");
try
{ //thread to sleep for the specified number of milliseconds
Thread.sleep(5000);
} catch (java.lang.InterruptedException ie) {
}
System.out.println("..... Oh you don't know what a 4-byte binary number is?");
System.out.println("That is just a 4 digit number consisting of any combination of 1's and 0's.");
System.out.println("i.e. 0001 or 1111 or 1010 etc...");
System.out.println("So go ahead and enter any 4 digit number in the space below and I will convert it to its binary counterpart.");
int binary1, decimal1; // declaration of the integer variables
binary1 = keyboard.nextLine();
decimal1 = Interger.parseInt(binary1,2); // converts binary to decimal see java documentation at http://docs.oracle.com/javase/6/docs/api/java/lang/Integer.html#parseInt%28java.lang.String,%20int%29
System.out.println("You entered " + binary1); // confirmation of the input
System.out.println("Abra-Cadabra");
System.out.println("Bippity Boppity");
System.out.println("Beep, Bop, Boop, eeerrrrr");
System.out.println("Now that is done the results are ");
System.out.println(+ decimal1);
}
Я получаю 1 ошибку при компиляции, и единственное, что показывает это B2Dconversion.java:42: ошибка: достигнут конец файла во время разбора
Любая помощь я могу получить было бы здорово.
Спасибо за ловить это. Теперь для настоящего удовольствия .... У меня есть новая ошибка. 'B2Dconversion.java:34: ошибка: не удается найти символ d1 = Interger.parsInt (b1,2); символ: переменная Interger местоположение: класс B2Dconversion ' Мне пришлось внести некоторые изменения, так что вот фрагмент кода, на который я верю, ссылается. \t \t int b1, d1; // объявление целочисленных переменных \t \t \t \t Сканер клавиатуры = новый сканер (System.in); \t \t b1 = keyboard.nextInt(); \t \t d1 = Interger.parseInt (b1,2); – RationalSolutions
'd1' simbol нет в вашем размещенном коде. это странно. Какова фактическая ошибка? – lakshman
Извините, я изменил код, чтобы упростить переменные, – RationalSolutions