2

I have tried the code below so many times but I am always getting the answer as 11.0.

This is an error as the answer should be 10.83 and I don't want to round off. How should I tackle this?

Here is the code

public class Question_4_Expression_Calculator {
    public static void main(String[] args) {
            // TODO Auto-generated method stub
            double a = 10;
            double b = 7/3;
            double c = 12/8;
            //double x = ((a)+(b)-(c));
            System.out.println("Result is "+ (double)(x);   
    }
}

danh
  • 62,181
  • 10
  • 95
  • 136
Saad Qazi
  • 29
  • 1
  • 3
    Does this answer your question? [Division of integers in Java](https://stackoverflow.com/questions/7220681/division-of-integers-in-java) – Chass Long Nov 30 '20 at 05:31

0 Answers0