View Single Post
  #1 (permalink)  
Old 03-19-2008, 05:24 AM
javakid9000 javakid9000 is offline
Member
 
Join Date: Nov 2007
Posts: 2
javakid9000 is on a distinguished road
CRC check program 1 error
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); } }
Reply With Quote
Sponsored Links