Page 507 - computer science (868) class 11
P. 507

56                      case 12:         hexVal += "C";        break;
                   57                      case 11:         hexVal += "B";         break;

                   58                      case 10:         hexVal += "A";         break;
                   59                      default:            hexVal += Integer.toString(dig);

                   60                  }
                   61                  num = num / 16;

                   62              }
                   63              System.out.print("Hexadecimal Value of " + num1 + " : " );
                   64              for (counter = hexVal.length() - 1; counter >= 0; counter--)

                   65                  System.out.print(hexVal.charAt(counter));

                   66          }
                   67
                   68          void deci_other()

                   69          {
                   70              int ch,t,num;

                   71              Scanner sc = new Scanner(System.in);
                   72              System.out.println("Enter number to convert : ");

                   73              num=sc.nextInt();
                   74              System.out.println("Enter 1 for Binary");

                   75              System.out.println("Enter 2 for Octal");
                   76              System.out.println("Enter 3 for Hexadecimal");

                   77              System.out.println("Enter 4 for Exit");
                   78              ch=sc.nextInt();

                   79              switch(ch)
                   80              {

                   81                  case 1 : dec2bin(num); break;
                   82                  case 2 : dec2oct(num); break;

                   83                  case 3 : dec2hex(num); break;
                   84                  default: System.out.println("Wrong Choice");

                   85              }
                   86              System.out.println("\n--------------------------------");

                   87          }
                   88
                   89          void bintodeci(int bin)





                                                                                                                       505
                                                                                                      Sample Projects  505
   502   503   504   505   506   507   508   509   510   511   512