aboutsummaryrefslogtreecommitdiff
path: root/CS2452/Q8.java
blob: 76c0bcb8689be7de3a461bdd1667e79fbaad21b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

public class Q8
{

	public static void main(String[] args)
	{
		int[] str= new int[(int) Math.ceil(args[0].length()/6.00)];
		
		args[0] = args[0].toLowerCase();
		
		while (args[0].length() % 6 != 0)
		{
			args[0] = args[0].concat(String.format("%c",'a' + 31));
		}
		
		for(int i = 0; i < str.length; i++)
		{
			str[i] = 0;
			for(int j = 0; j < 6; j++)
			{
				str[i] <<= 5;
				str[i] += args[0].charAt(j + (i*6)) - 'a' ;
			}
		}
		
		for(int i = 0; i < str.length; i++)
		{
			System.out.printf("%x\n", str[i]);
		}

	}

}