//Computer Programming Class
//Author: Seif Al Salem
import java.util.Scanner;
class Main {
public static void main(String[] args) {
//here are the strings for the code
String lineFromInput;
String finalHexMessage = "";
String finalDecimalMessage = "";
String finalBinaryMessage = "";
String finalASCIIMessage = "";
String ascii = "";
//the scanner to read the input
Scanner s = new Scanner(System.in);
//here is the while loop where everything is happening
while(s.hasNextLine())
{
lineFromInput=s.nextLine();
int decimal = Integer.parseInt(lineFromInput, 16);
//here are the equations for hex, decimal and Binary
finalHexMessage = finalHexMessage + lineFromInput; //take original hex values
finalDecimalMessage = finalDecimalMessage + Integer.parseInt(lineFromInput, 16); //convert to decimal
finalBinaryMessage = finalBinaryMessage + Integer.toBinaryString(decimal); //convert to binary
// This equation is for converting from to letters (char)
for (int i = 0; i < lineFromInput.length(); i += 2) {
String part = lineFromInput.substring(i, i + 2);
char ch = (char)Integer.parseInt(part, 16);
ascii = ascii + ch;}
}
//print out all of the final messages
System.out.println("HEX MESSAGE:"+finalHexMessage);
System.out.println("DECIMAL MESSAGE:"+finalDecimalMessage);
System.out.println("BINARY MESSAGE:"+finalBinaryMessage);
System.out.println("ASCII Message: " + ascii);
}
}