import java.util.Scanner;
public class Name {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String A= "10", B = "11", C = "12", D = "13", E = "14" , F = "15";
System.out.println("Enter your nubmer/letter: ");
char number = input.next().charAt(0);
System.out.println("Enter your number system: ");
char system = input.next().charAt(0);
//while( system == 2) {
//if ( number % 2 != 0)
//}
//I want this to be an algorithm to convert binary
//into decimal, but I don't know how it can add
//the constant changes in the power of 2
if ( system == '10') {
System.out.println( "Your decimal number is" + number );
} else if (system == '16') {
System.out.println( "Your decimal number is" + number );
} else {
System.out.println(" Error ");
}
}
}
我试过了,但它会自动进入错误。有人能告诉我我做错了什么吗?我正在尝试将二进制或十六进制数字转换为十进制。