// TS8802 Project by John Phillips on 6/24/2003 last revised 6/26/2003

public class BinToHex extends Problem {
  
  public BinToHex()
  {
    newProblem();
  }

  public void newProblem()
  {
    int decNum = ( int ) ( Math.random() * 65535 );
    String binNum = Integer.toString( decNum, 2 );
    String hexNum = Integer.toString( decNum, 16 );
    setAnswer( hexNum );
    setQuestion( "Use pencil and paper to solve the following problem:\n\n" + 
      "Convert the binary number " + binNum + " to hex." );
  }

  public String hint()
  {
    return "To convert a binary number to a hex number look at the number 4 bits " +
           "at a time starting at the rightmost bit. Each grouping of 4 bits will have " +
           "column weightings of 8, 4, 2, and 1. For example, the binary number 1011110 could " +
           "be grouped as 101 1110 and would then be the hex number 5E.";
  }

}