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.
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);
}
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.
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);
}