This are the 3 codes that i would like to become as one...
THIS IS THE FIRST ONE
THIS IS THE SECOND
THIS IS THE THIRD
I appreciate your replies
/>/>
THIS IS THE FIRST ONE
import java.lang.*;
import java.io.*;
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("The Binary Value is: " + by);
}
}
THIS IS THE SECOND
import java.io.*;
import java.lang.*;
class decimaltooctal {
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the Decimal Value: ");
String deci = bf.readLine();
int value = Integer.parseInt(deci);
String str = Integer.toString(value,8);
System.out.println("The Octal Value is: " + str);
}
}
THIS IS THE THIRD
import java.util.*;
class decimaltohexa {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the Decimal Value: ");
int i = in.nextInt();
String strHexNumber = Integer.toHexString(i);
System.out.println("The Hexa Value is: " + strHexNumber);
}
}
I appreciate your replies