SHARE
TWEET

Ejercicio Entero Hex

a guest Nov 3rd, 2015 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner
  2. public class Ejercicio{
  3.    
  4.     public static void main(String [] args){
  5.         Scanner scan = new Scanner(System.in);
  6.         System.out.print("Pegar Hex: ");
  7.         String hex =scan.nextLine();
  8.         String [] arr= hex.split(" ");
  9.         String num [] = new String [arr.length];
  10.         for(int i = 0; i < num.length;i++){
  11.             int he = Integer.decode(arr[i]);
  12.             if(he%2 == 0){
  13.                 num[i] = Integer.toHexString(he+1);
  14.             }else{
  15.                 num[i] = Integer.toHexString(he-1);
  16.             }
  17.             System.out.print((char)Integer.parseInt(num[i], 16));
  18.         }
  19.         System.out.println();
  20.     }
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top