Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

How can these 3 codes become one only(combine all 3 codes to be one)?

$
0
0
This are the 3 codes that i would like to become as one...

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 :D/>/>

Viewing all articles
Browse latest Browse all 51036

Trending Articles