I would like how can I include the decimal result from the dance method to the light one. For example, in this program, if I input 5F, the decimal result would be 95. Well, I want that 95 to appear as a static int variable in the light method in order to be converted into a binary number. It would be also very helpful if you could tell me how can I limit the hexadecimal number to only 2 figures. Thanks for reading!
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class test2 {
public static void main(String args[]) throws Exception{
DANCE(args);
LIGHTS(args);
}
public static void DANCE(String[]args) throws Exception {
BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter hex no:"+"");
int no= Integer.parseInt(reader.readLine(), 16);
System.out.println("Decimal no:"+no);
}
public static void LIGHTS(String a[]){
System.out.println("Binary representation: ");
System.out.println(Integer.toBinaryString(no));
}
}