Results 1 to 4 of 4

Thread: Multiplying Variables in java

  1. #1
    Join Date
    Nov 2009
    Posts
    330

    Multiplying Variables in java

    Hi friends
    I program in java and so I use the best IDE for it, that it I use Eclipse IDE but the problem is that I am having a error on my varaible declaration line after I type every third line. Please check, I have posted it below
    Code:
    import java.math.*;
    .
    .
    .
    .
    .
    double cnt, energycnt, transRange;
    energycnt = cnt * Math.pow(transRange,2);
    Any idea on this. Please.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Multiplying Variables in java

    Hi
    Please check the following code, this may help you.
    Code:
    public class sennode {
    private int xcord;
    private int ycord;
    private double energyLevel;
    public sennode(int xInit, int yInit, double newEnergy){
    xcord = xInit;
    ycord = yInit;
    energyLevel = newEnergy;
    }
    
    double const = 0 ;
    double energycnt = 0;
    double transRange = 0;
    
    energycnt = const * Math.pow(transRange,2);
    }

  3. #3
    Join Date
    Nov 2009
    Posts
    330

    Re: Multiplying Variables in java

    Hi
    Thanks for your help and your code.
    I have read your code in details but unfortunately that is not the problem for sure. May be you can try something different. Thanks again.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Multiplying Variables in java

    Hi
    May be this code can help you
    Code:
    public class sensorNode {
    
    	private int xcord;
    	private	int ycord;
    	private	double energyLevel;	
    	
    	/**
    	 * @param xInit the x-coordinate for node
    	 * @param yInit the y-coordinate for node
    	 * @param newEnergy the initial energy for node
    	 */
    	public  sensorNode(int xInit, int yInit, double newEnergy){
    		
    		xcord = xInit;
    		ycord = yInit;
    		energyLevel = newEnergy;
    	}
    
    	double const = 0 ;
    	double energycnt = 0;
    	double transRange = 0;
    
    	energycnt = const * Math.pow(transRange,2);
    	
    }

Similar Threads

  1. What are an Atomic Variables in Java?
    By Dilbert in forum Software Development
    Replies: 5
    Last Post: 04-01-2011, 07:51 PM
  2. About instance variables in java
    By Khaled11 in forum Software Development
    Replies: 1
    Last Post: 19-03-2010, 02:38 PM
  3. Java properties / variables dynamically
    By Miles Runner in forum Software Development
    Replies: 5
    Last Post: 04-03-2010, 11:31 AM
  4. What is Instance variables in Java?
    By Owen Fernandes in forum Software Development
    Replies: 5
    Last Post: 23-01-2010, 08:27 AM
  5. Java bans Global Variables
    By KALLIYAN in forum Software Development
    Replies: 4
    Last Post: 10-11-2009, 04:17 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,668,905.36422 seconds with 17 queries