Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DeziHexa {
- public static void main(String[] args) {
- char hexadezimalzeichen[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
- String hexadezimale = "";
- Scanner scanner = new Scanner (System.in);
- int dezimale = scanner.nextInt();
- if(dezimale >= 0) {
- while(dezimale > 0) {
- int rest = dezimale % 16;
- hexadezimale = hexadezimalzeichen[rest] + hexadezimale;
- dezimale /= 16;
- }
- System.out.println(hexadezimale);
- }else
- System.out.println("ungültige Eingabe");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement