Which OS are you in?
Sorry there Ken JS. I'm struggling to remember this stuff but I thought that the parity check matrix was generally binary. Because your G is not in binary, I don't think you can apply (mod 2) to it, so I would say that your first P^t is correct. I must stress that I'm not 100% sure about this though, is there someone else out there that knows this for sure?
That's incorrect. It was only required in C89/90. C++ never had such requirement. Even C99 removes this restriction.
I stand corrected - apologies.
Yes dougy83 that is what i was getting at, but I didn't want to give away the answer. :P
Minor point: don't forget that in C++ you must initialise your variable outside the for loop:
int e;
for (e=2; e<=n; e+=2)
The statement
e=e%2;
will result in e being equal to the remainder of the division of e by 2. In other words, if e is even, e will become 0, if e is odd, e will become 1, and e will not change after that no matter how many times you loop.
To display the sum of all even numbers, you will need TWO variables, one for the sum and one for the even numbers. You should loop according to the even numbers until you get to n, add add them up using the sum.
Have a go and let us know if you need more help.
Cheers
darkagn
private void handleNextButton() { //Decrement the index index--; //If index is less than 0, wrap around to the last element of the array if ( index < 0) { index = dvd.length + 1; }//End if
First, I think
index--;
should be
index++;
and the if statement should read
if (index>=dvd.length)
{
index = 0;
}
I think a similar problem is occurring for the
handleLastButton()
method.
For the icon, try an absolute address and see what happens. If that doesn't work, repost and we'll try to think of something else...
Hope this helps,
darkagn
Wow, that's a lot of code to wade through. Perhaps you could repost with the section that contains the buttons and icon that don't work so it is easier to find?
In binary, -1=1, so -P^t=P^t. What you have done looks good to me, but maybe someone else can check for you also? It's a long time since I did this sort of thing...
Hi Laseredd,
That short program looks good! I think you have shown understanding of some very important C++ principles here, classes, methods, I/O. :)
As an extension, how do you think you would go about accepting either integers or floats rather than just integers? Can you think of how your Calc class might be written to accept two strings and concatenate them together (add the second onto the end of the first)?
darkagn
My experience with NetBeans is that the generated code when building GUIs in particular is extremely difficult to read and subsequently maintain. For a beginner I would recommend something like jEdit. While technically not an IDE it has several downloadable plugins through its sophisticated plugin manager that add functionality to make it IDE-like, but still encourages students to write their own code. After all, it is the only real way to learn.
jEdit is free to use and has syntax highlighting for a variety of languages, but is designed specifically with java in mind. Check out their website for further details.
and just an advice if i were u i would combine the two fuctions from my perspective it would make things much easier for me.
Don't do that. It is much better programming practice to separate functions where possible. Imagine if you had to call
int Add (int x, int y)
ten times with different variables for parameters? Or a hundred times? It is much easier to have
c=Add(a,b);
a hundred times than the details of the function.
Just my 2 cents worth...
darkagn
Hi Shaqnolysis,
I think you have a good place to start with the BufferedReader class, but it might pay to have a good read of the Java API for that class. It's probably a good idea to bookmark this link as I can assure you it will be very valuable throughout your Java programming career!
I hope I have given you a good place to start, but let us all know if you need any more help.
Cheers
darkagn