Results 1 to 15 of 15
Thread: Int equals void
- 05-05-2010, 03:08 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 14
- Rep Power
- 0
Int equals void
I am building a applet that can read inputs from the user to make codons for DNA, so my teacher can use it. It reads the first three characters to make a codon, uses those characters to get a value (1, 2, 3 or 4), takes those character values to make a codon value (1 - 64), and then changes that codon value into the Amino Acid name. I am trying to take this int value, called codonNumber, and make it equal a different number, called from a void called getCodon. Can anyone help me? This is my error:
And this is the section of code I have the error in:Java Code:/tmp/jc_20900/DNA.java:144: getCodon(int) in DNA cannot be applied to () codonNumber = getCodon(); ^ 1 error
For your information, the brackets are correct, its just that the second closing bracket is the last ending bracket for my Main method. =pJava Code:if(firstInput != 0 && secondInput != 0 && thirdInput != 0) { codonNumber = getCodon(); } } public static void getCodon(int codonNumber){ if(firstInput == 1) { if(secondInput == 1) { if(thirdInput == 1) { codonNumber = 1; } else if(thirdInput == 2) { codonNumber = 2; } else if(thirdInput == 3) { codonNumber = 3; } else if(thirdInput == 4) { codonNumber = 4; } } else if(secondInput == 2) { if(thirdInput == 1) { codonNumber = 5; } else if(thirdInput == 2) { codonNumber = 6; } else if(thirdInput == 3) { codonNumber = 7; } else if(thirdInput == 4) { codonNumber = 8; } } else if(secondInput == 3) { if(thirdInput == 1) { codonNumber = 9; } else if(thirdInput == 2) { codonNumber = 10; } else if(thirdInput == 3) { codonNumber = 11; } else if(thirdInput == 4) { codonNumber = 12; } } else if(secondInput == 4) { if(thirdInput == 1) { codonNumber = 13; } else if(thirdInput == 2) { codonNumber = 14; } else if(thirdInput == 3) { codonNumber = 15; } else if(thirdInput == 4) { codonNumber = 16; } } } else if(firstInput == 2) { if(secondInput == 1) { if(thirdInput == 1) { codonNumber = 17; } else if(thirdInput == 2) { codonNumber = 18; } else if(thirdInput == 3) { codonNumber = 19; } else if(thirdInput == 4) { codonNumber = 20; } } else if(secondInput == 2) { if(thirdInput == 1) { codonNumber = 21; } else if(thirdInput == 2) { codonNumber = 22; } else if(thirdInput == 3) { codonNumber = 23; } else if(thirdInput == 4) { codonNumber = 24; } } else if(secondInput == 3) { if(thirdInput == 1) { codonNumber = 25; } else if(thirdInput == 2) { codonNumber = 26; } else if(thirdInput == 3) { codonNumber = 27; } else if(thirdInput == 4) { codonNumber = 28; } } else if(secondInput == 4) { if(thirdInput == 1) { codonNumber = 29; } else if(thirdInput == 2) { codonNumber = 30; } else if(thirdInput == 3) { codonNumber = 31; } else if(thirdInput == 4) { codonNumber = 32; } } } else if(firstInput == 3) { if(secondInput == 1) { if(thirdInput == 1) { codonNumber = 33; } else if(thirdInput == 2) { codonNumber = 34; } else if(thirdInput == 3) { codonNumber = 35; } else if(thirdInput == 4) { codonNumber = 36; } } else if(secondInput == 2) { if(thirdInput == 1) { codonNumber = 37; } else if(thirdInput == 2) { codonNumber = 38; } else if(thirdInput == 3) { codonNumber = 39; } else if(thirdInput == 4) { codonNumber = 40; } } else if(secondInput == 3) { if(thirdInput == 1) { codonNumber = 41; } else if(thirdInput == 2) { codonNumber = 42; } else if(thirdInput == 3) { codonNumber = 43; } else if(thirdInput == 4) { codonNumber = 44; } } else if(secondInput == 4) { if(thirdInput == 1) { codonNumber = 45; } else if(thirdInput == 2) { codonNumber = 46; } else if(thirdInput == 3) { codonNumber = 47; } else if(thirdInput == 4) { codonNumber = 48; } } } else if(firstInput == 4) { if(secondInput == 1) { if(thirdInput == 1) { codonNumber = 49; } else if(thirdInput == 2) { codonNumber = 50; } else if(thirdInput == 3) { codonNumber = 51; } else if(thirdInput == 4) { codonNumber = 52; } } else if(secondInput == 2) { if(thirdInput == 1) { codonNumber = 53; } else if(thirdInput == 2) { codonNumber = 54; } else if(thirdInput == 3) { codonNumber = 55; } else if(thirdInput == 4) { codonNumber = 56; } } else if(secondInput == 3) { if(thirdInput == 1) { codonNumber = 57; } else if(thirdInput == 2) { codonNumber = 58; } else if(thirdInput == 3) { codonNumber = 59; } else if(thirdInput == 4) { codonNumber = 60; } } else if(secondInput == 4) { if(thirdInput == 1) { codonNumber = 61; } else if(thirdInput == 2) { codonNumber = 62; } else if(thirdInput == 3) { codonNumber = 63; } else if(thirdInput == 4) { codonNumber = 64; } } } }
- 05-05-2010, 03:13 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
- 05-05-2010, 03:18 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Am I right that the codon number equals:
16*(firstInput-1)+4*(secondInput-1)+thirdInput?
kind regards,
Jos
- 05-05-2010, 04:17 PM #4
Member
- Join Date
- Mar 2010
- Posts
- 14
- Rep Power
- 0
Ummmmmm, no. Lol. That isn't how I had the formula. I think I know how to fix it now.
- 05-05-2010, 04:42 PM #5
Uhm, I think this is close to what you need:
That would reduce the nested ifs a little.Java Code:String s4 = String.valueOf(firstInput -1) + String.valueOf(secondInput -1) + String.valueOf(thirdInput -1); codonNumber = Integer.parseInt(s4, 4) +1;
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 05-05-2010, 04:48 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
- 05-05-2010, 04:51 PM #7
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 05-05-2010, 04:53 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
- 05-05-2010, 04:58 PM #9
Aye sir, off to the quarry.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 05-05-2010, 05:12 PM #10
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
- 05-05-2010, 06:10 PM #11
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
- 05-05-2010, 06:17 PM #12
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Oh great, I don't pay attention for one meager minute and they sort it all out behind my back, it's not fair! What'd happen if I started to sort things out behind their backs? Hm? That's what I'm all about, it's not fair! So there.
kind regards,
Jos (<--- staring at the folks with the syringes and their white coats ... ;-)
- 05-06-2010, 03:33 PM #13
Member
- Join Date
- Mar 2010
- Posts
- 14
- Rep Power
- 0
Lol thanks guys for posting. I just called the void instead of making the getCodon equal the void. I mean, if you looked inside the getCodon method, you could see that it would already happen. =p Now I have to make Jmenu buttons with actions, so commands like "Transcribe" and "Translate" will work. Any help with that would be nice, or just send a URL of where it could teach it noob friendly.
- 05-06-2010, 03:38 PM #14
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Well, in the original posted code your codonNumber might be being set in the method, but it's not being past out. For example this call:
codonNumber will always be zero after that call, whatever happens in the getCodon() method.Java Code:int codonNumber = 0; getCodon(codonNumber);
- 05-06-2010, 03:44 PM #15
Member
- Join Date
- Mar 2010
- Posts
- 14
- Rep Power
- 0
Similar Threads
-
'void' type not allowed here
By Torgero in forum New To JavaReplies: 15Last Post: 10-04-2008, 11:08 PM -
name clash: equals(E) in and equals(java.lang.Object)
By AdRock in forum New To JavaReplies: 0Last Post: 01-25-2008, 11:13 PM -
The different of static void,protected,and void in methods?
By Winarto in forum New To JavaReplies: 5Last Post: 01-24-2008, 11:53 PM -
is void a type?
By mary in forum New To JavaReplies: 3Last Post: 08-01-2007, 08:12 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks