اكتب برنامج Java لتحويل الرقم الثنائي المعطى إلى الرقم العشري المكافئ له
- برمجة
- برمجة جافا
- 2021-09-28
- moh2177769644130246
الأجوبة
-
import java.util.Scanner;
-
class Binary_Decimal -
{ -
Scanner scan; -
int num;
-
void getVal()
-
{ -
System.out.println("Binary to Decimal");
-
scan = new Scanner(System.in);
-
System.out.println("\nEnter the number :");
-
num = Integer.parseInt(scan.nextLine(), 2);
-
} -
void convert()
-
{ -
String decimal = Integer.toString(num);
-
System.out.println("Decimal Value is : " + decimal);
-
} -
} -
class MainClass -
{ -
public static void main(String args[])
-
{ -
Binary_Decimal obj = new Binary_Decimal();
-
obj.getVal();
-
obj.convert();
-
} -
} -
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال