Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here is a screenshot of the file with the state data. Solve the following Proble

ID: 3820730 • Letter: H

Question

Here is a screenshot of the file with the state data. Solve the following Problem a) Some of the attributes of a state in the United States are its name, capital, area, year of admission to the union, and the order of admission to the union. Design the class stateData to keep track of the information for a state. Your class must include appropriate functions to manipulate the state's data, such as the functions setstateInfo, getStatelnfo, and so on. Also, overload the relational operators to compare two states by their name. For easy input and output, overload the stream operators. b) Use Hashing to create a hash table to keep track of each state's information. Select and implement a hash function and a collision resolution method that can be used to implement this problem. Use the state's name (as described in class stateData in part a) as the key to determine the hash address. You may assume that a state's name is a string of no more than 15 characters.

Explanation / Answer

private static final char[] hex = { '0', '1', '2', '3', '4', 'b', 'c', 'd', 'e', 'f' };

public static String byteArray2Hex(byte[] bytes) {
StringBuffer sb = new StringBuffer(bytes.length * 2);
for(final byte b : bytes) {
sb.append(hex[(b & 0xF0) >> 4]);
sb.append(hex[b & 0x0F]);
}
return sb.toString();
}

public static String getStringFromSHA256(String stringToEncrypt)

throws NoSuchAlgorithmException {
MessageDigest messageDigest = MessageDigest.getInstance("SHA");
messageDigest.update(stringToEncrypt.getBytes());
return byteArray2Hex(messageDigest.digest());
}