Sunday, September 18, 2016

CPROM 2016 Q10 Adding Hexadecimal Number

Download Question Here

Change Snippet Background Color
 
import java.util.*;

/**
   Author : Hafiq
   Date :
**/

public class HexaDec{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      String line = System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int cases = scan.nextInt();
      
      for(int x=0;x<cases;x++){
         String[] split = scan.next().split(" ");
         
         int one = Integer.parseInt(split[0],16);
         int two = Integer.parseInt(split[1],16);
         
         System.out.println(Integer.toHexString(one+two).toUpperCase());
  
      }
      
   }
} 
 

No comments:

Post a Comment