i'm trying to make a CRC calculator in Java and for some reason i'm having and issue with the "%" operator when trying to get a remainder. Any help would be greatly appreciated:
/*Programmer: Your Name Here
Date: July 30, 2007
Class: ITCS 3160
Professor: Cloyd Goodrum
Program name: CRC.java
Description: Write a program to read in a 16 bit string and a 4 bit generator polynomial. */
import javax.swing.JOptionPane;
public class CRC
{
public static void main (String[] args)
{
int Orig;
int Gen;
int CRC;
String original = JOptionPane.showInputDialog ("Please enter the binary message to be sent.");
String generator = JOptionPane.showInputDialog ("Please enter the 4-bit binary generator.");
Orig = Integer.parseInt (original,2);
String OrigBinary = Integer.toBinaryString(Orig);
System.out.println("Original Message: " + OrigBinary);
Gen = Integer.parseInt (original,2);
String GenBinary = Integer.toBinaryString(Gen);
System.out.println("Generator: " + GenBinary);
CRC = OrigBinary % GenBinary;
System.out.println("CRC remainder: " + CRC);
}
}