Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class DecimalToHexa {
- public static void main(String args[]) {
- int n = 0;
- Scanner in = new Scanner(System.in);
- System.out.println("Enter a number ");
- n = in.nextInt();
- for(int i=1; i<=n; i++) {
- System.out.println(i + "t" + Integer.toHexString(i));
- }
- }
- }
- Enter a number 14
- 1 1
- 2 2
- 3 3
- 4 4
- 5 5
- 6 6
- 7 7
- 8 8
- 9 9
- 10 a
- 11 b
- 12 c
- 13 d
- 14 e
- public static void main(String args[]) {
- int n = 0;
- Scanner in = new Scanner(System.in);
- System.out.println("Enter a number ");
- n = in.nextInt();
- for (int i = 1; i <= n; i++) {
- System.out.println(i + "t" + Integer.toHexString(i).toUpperCase());
- }
- }
- Integer.toHexString(i).toUpperCase()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement