I'm not sure. This the right way to calculate percentage ?
Here's my method

public class percent extends Operation {

    @Override
    public Value calculate(Value key, Value value) {

     //BigDecimal result = key.getValue().divide(Value.hundred, Value.SCALE, BigDecimal.ROUND_UP);
       return new Value((key.getValue().divide(value.getValue()).multiply(Value.hundred)));
     //  return new Value(result);




    }

    @Override
    public String getSymbol() {
        return "%";
    }


}

**// means doesn't work as well

My short course of percent calculation:

  1. 1 =100% <=> 1% = 0.01
  2. Percent calculation does not exist, it is just multiplication.

Everything else follows from these two facts.

Thanks you a lot sir

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.