Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import java.util.Scanner;
  2. class DecimalToHexa {
  3. public static void main(String args[]) {
  4. int n = 0;
  5. Scanner in = new Scanner(System.in);
  6.  
  7. System.out.println("Enter a number ");
  8. n = in.nextInt();
  9. for(int i=1; i<=n; i++) {
  10. System.out.println(i + "t" + Integer.toHexString(i));
  11. }
  12.  
  13. }
  14. }
  15.  
  16. Enter a number 14
  17. 1 1
  18. 2 2
  19. 3 3
  20. 4 4
  21. 5 5
  22. 6 6
  23. 7 7
  24. 8 8
  25. 9 9
  26. 10 a
  27. 11 b
  28. 12 c
  29. 13 d
  30. 14 e
  31.  
  32. public static void main(String args[]) {
  33. int n = 0;
  34. Scanner in = new Scanner(System.in);
  35.  
  36. System.out.println("Enter a number ");
  37. n = in.nextInt();
  38. for (int i = 1; i <= n; i++) {
  39. System.out.println(i + "t" + Integer.toHexString(i).toUpperCase());
  40. }
  41. }
  42.  
  43. Integer.toHexString(i).toUpperCase()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement