اخي الكريم يبدو لي اني استعملت هذه الطريقه وإن لم يكن كذالك اتمنى ان تحدد لي الكود بالضبط
ثانياً : ماكنت اريده جزاك الله خير هو ان اجمع هذه الاكواد في برنامج واحد بحيث يتم تنفيذها في آن واحد
وهذه إعاده للعرض بالتنسيق...
خالص التحــــــــــــايا ..>>"
import java.lang.*;
import java.io.*;
public class DecimalToBinary{
public static void main(String args[]) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the decimal value:");
String hex = bf.readLine();
int i = Integer.parseInt(hex);
String by = Integer.toBinaryString(i);
System.out.println("Binary: " + by);
}
}
import java.io.*;
import java.lang.*;
public class BinaryToHexa{
public static void main(String[] args)throws IOException{
BufferedReader bf= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the Binary number:");
String hex = bf.readLine();
long num = Long.parseLong(hex);
long rem;
while(num > 0){
rem = num % 10;
num = num / 10;
if(rem != 0 && rem != 1){
System.out.println("This is not a binary number.");
System.out.println("Please try once again.");
System.exit(0);
}
}
int i= Integer.parseInt(hex,2);
String hexString = Integer.toHexString(i);
System.out.println("Hexa decimal: " + hexString);
}
}
import java.io.*;
import java.lang.*;
public class HexadecimalToBinaryAndLong{
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the hexa value!");
String hex = bf.readLine();
int i = Integer.parseInt(hex);
String by = Integer.toBinaryString(i);
System.out.println("This is Binary: " + by);
long num = Long.parseLong(hex,16);
System.out.println("This is long:=" + num);
}
}
import java.io.*;
import java.lang.*;
public class DecimalToOctal {
public static void main(String[] args) throws IOException{
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the decimal number:");
String deci = buff.readLine();
int value = Integer.parseInt(deci);
String str = Integer.toString(value,8);
System.out.println("octal:=" + str);
}
}
import java.util.Scanner;
class BinaryToOctal
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a binary number: ");
String binaryNumber = scanner.nextLine();
int myInt = Integer.parseInt(binaryNumber, 2);
System.out.println(binaryNumber + " in Binary, is "
+ Integer.toString(myInt, 8) + " in Octal");
}
}
import java.io.*;
import java.lang.*;
public class DecimalToHexadecimal{
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the decimal value:");
String hex = bf.readLine();
int i = Integer.parseInt(hex);
String hex1 = Integer.toHexString(i);
System.out.println("Hexa decimal: " + hex1);
}
}
import java.util.Scanner;
public class BinarytoDecimal{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter a binary number:");
System.out.println("Decimal result: "+Long.parseLong(input.nextLine(), 2));
}
}
import java.io.*;
import java.lang.*;
public class HexadecimalToDecimal{
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the Hexadecimal number:");
String str= bf.readLine();
int i= Integer.parseInt(str,16);
System.out.println("Decimal:="+ i);
}
}
import java.io.*;
import java.lang.*;
public class OctalToDecimal{
public static void main(String[] args)throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the octal number:");
String oct = reader.readLine();
int i= Integer.parseInt(oct,8);
System.out.println("Decimal:=" + i);
}
}
import java.io.*;
import java.lang.*;
public class HexadecimalToOctal{
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the hexa value!");
String hex = bf.readLine();
int i = Integer.parseInt(hex);
String str = Integer.toString(i,8);
System.out.println("octal:=" + str);
}
}

