Results 1 to 15 of 15

Thread: Int equals void

  1. #1
    Join Date
    Mar 2010
    Posts
    14
    Rep Power
    0

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

    Java Code:
    /tmp/jc_20900/DNA.java:144: getCodon(int) in DNA cannot be applied to ()
    			codonNumber = getCodon();
    			              ^
    1 error
    And this is the section of code I have the error in:

    Java 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;
    				}
    
    			}
    
    		}
    
    	}
    For your information, the brackets are correct, its just that the second closing bracket is the last ending bracket for my Main method. =p

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,773
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Insomniac Riot View Post
    Java Code:
    /tmp/jc_20900/DNA.java:144: getCodon(int) in DNA cannot be applied to ()
    			codonNumber = getCodon();
    			              ^
    1 error
    Your getCodon( ... ) method needs an int parameter; you are not supplying it an int, you are trying to call that method without any parameters at all; that makes your compiler whine at you.

    kind regards,

    Jos

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,773
    Blog Entries
    7
    Rep Power
    21

    Default

    Am I right that the codon number equals:

    16*(firstInput-1)+4*(secondInput-1)+thirdInput?

    kind regards,

    Jos

  4. #4
    Join Date
    Mar 2010
    Posts
    14
    Rep Power
    0

    Default

    Ummmmmm, no. Lol. That isn't how I had the formula. I think I know how to fix it now.

  5. #5
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    Uhm, I think this is close to what you need:
    Java Code:
    String s4 = String.valueOf(firstInput -1) + String.valueOf(secondInput -1) + String.valueOf(thirdInput -1);
    codonNumber = Integer.parseInt(s4, 4) +1;
    That would reduce the nested ifs a little.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,773
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Insomniac Riot View Post
    Ummmmmm, no. Lol. That isn't how I had the formula. I think I know how to fix it now.
    Strange, because that little formula works for me; please elaborate and show us the magic secret! ;-)

    kind regards,

    Jos

  7. #7
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    Quote Originally Posted by JosAH View Post
    Strange, because that little formula works for me; please elaborate and show us the magic secret! ;-)

    kind regards,

    Jos
    Gaaah, I didn't see the -1 in your formula :D
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,773
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by PhHein View Post
    Gaaah, I didn't see the -1 in your formula :D
    You go and bite those numbers in stone with your teeth!

    kind regards,

    Jos ;-)

  9. #9
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    Aye sir, off to the quarry.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  10. #10
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,773
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by PhHein View Post
    Aye sir, off to the quarry.
    And don't call me Miss!

    kind regards,

    Jos ;-)

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    Quote Originally Posted by JosAH View Post
    Your getCodon( ... ) method needs an int parameter; you are not supplying it an int, you are trying to call that method without any parameters at all; that makes your compiler whine at you.

    kind regards,

    Jos
    Then they'll get an error because getCodon doesn't actually return anything (void), and they're assigning that to the int.

    But it's apparently all sorted now...:)

  12. #12
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,773
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Tolls View Post
    But it's apparently all sorted now...:)
    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 ... ;-)

  13. #13
    Join Date
    Mar 2010
    Posts
    14
    Rep Power
    0

    Default

    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.

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    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:

    Java Code:
    int codonNumber = 0;
    getCodon(codonNumber);
    codonNumber will always be zero after that call, whatever happens in the getCodon() method.

  15. #15
    Join Date
    Mar 2010
    Posts
    14
    Rep Power
    0

Similar Threads

  1. 'void' type not allowed here
    By Torgero in forum New To Java
    Replies: 15
    Last Post: 10-05-2008, 12:08 AM
  2. Replies: 0
    Last Post: 01-26-2008, 12:13 AM
  3. Replies: 5
    Last Post: 01-25-2008, 12:53 AM
  4. is void a type?
    By mary in forum New To Java
    Replies: 3
    Last Post: 08-01-2007, 09:12 PM

Posting Permissions

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