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

public class percent extends Operation {

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


    public String getSymbol() {
        return "%";


**// means doesn't work as well

Recommended Answers

All 2 Replies

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, learning, and sharing knowledge.