You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
have access to post topics
communicate privately with other members (PM)
not see advertisements between posts
have the possibility to earn one of our surprises if you are an active member
access many other special features that will be introduced later.
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:
Code:
/*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);
}
}