Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

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.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-19-2008, 05:24 AM
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); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-19-2008, 06:04 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,022
hardwired is on a distinguished road
The variables "Orig" and "Gen" are assigned the same value, viz,
Code:
Orig = Integer.parseInt (original,2); Gen = Integer.parseInt (original,2);
Perhaps you intended
Code:
Gen = Integer.parseInt (generator,2);
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
spell check kazitula Java Applets 2 12-20-2007 12:37 PM
how to check available resources in java program lealea New To Java 3 08-13-2007 09:35 PM
Error: Cannot delete a.txt:It is being used by another person or program trill Advanced Java 1 08-07-2007 08:34 AM
Error :Invalid path, C:\Program Files\Java\j2re1.4.2_06\bin\javac.exe silvia New To Java 2 07-30-2007 09:55 AM
Error: Could Not Find Main Class. Program Will Exit silvia New To Java 1 07-19-2007 05:58 PM


All times are GMT +3. The time now is 12:50 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org