Results 1 to 2 of 2
  1. #1
    javakid9000 is offline Member
    Join Date
    Nov 2007
    Posts
    2
    Rep Power
    0

    Default 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:

    Java 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);
    	}
    }

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    The variables "Orig" and "Gen" are assigned the same value, viz,
    Java Code:
    	Orig = Integer.parseInt (original,2);
    	
    	Gen = Integer.parseInt (original,2);
    Perhaps you intended
    Java Code:
    	Gen = Integer.parseInt (generator,2);

Similar Threads

  1. Replies: 2
    Last Post: 09-22-2011, 10:48 PM
  2. spell check
    By kazitula in forum Java Applets
    Replies: 2
    Last Post: 12-20-2007, 12:37 PM
  3. how to check available resources in java program
    By lealea in forum New To Java
    Replies: 3
    Last Post: 08-13-2007, 09:35 PM
  4. Replies: 1
    Last Post: 08-07-2007, 08:34 AM
  5. Replies: 2
    Last Post: 07-30-2007, 09:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •