java - Divide values from a class extending number -


i have class extends number.

public class quantity extends number{  } 

and class as,

public class test{  quantity tkphmaxvalue; quantity tkphvalue;   public test(quantity tkphvalue, quantity maxvalue){     this.tkphvalue= tkphvalue;     this.maxvalue= maxvalue;  }    public quantity gettkphvalue() {     return tkphvalue; }  public void settkphvalue(quantity tkphvalue) {     this.tkphvalue = tkphvalue; }    public quantity gettkphmaxvalue() {     return tkphmaxvalue; }  public void settkphmaxvalue(quantity maxvalue) {     this.tkphmaxvalue = maxvalue; }  } 

i need divide ((gettkphvalue()/gettkphmaxvalue())*100) percentage value. how can convert quantity object number?

try this:

((gettkphvalue().doublevalue()/gettkphmaxvalue().doublevalue())*100) 

before do, make sure tkphmaxvalue , tkphvalue not null.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -