javaassociativity

Not getting the right answer from celcius to farenheit


static void CToF(float c){

        float f=32+((9/5)*c);
        System.out.printf("%.2f",f);


    }

  public static void main(String[] args) {

        CToF(27);

        sc.close();
    }

Here the priority of the * and / same so according to their associativity , it will execute from right to left.

So that 9/5 executed first and after that it multiplies with c so the answer is 80.60 but I got 59.00.

What's the problem?


Solution

  • if I make some change and write like this

    float f=32+(c*9/5);

    it works.xD