#Having trouble with divide() method

4 messages · Page 1 of 1 (latest)

sharp pasture
#

I keep failing the last test which should divide a and b correctly and I'm not sure why. Would very much appreciate the help.

​Error description:
divide() method is not dividing 4020 & 4035 correctly

java
public class ArithmeticWrapper {
    private static class Arithmetic{
        private int a;
        private int b;
     
        public Arithmetic(int a, int b){
            this.a = a;
            this.b = b;
        }
        
        public int getA(){
            return a;
        }
        
        public void setA(int a){
            this.a = a;
        }
        
        public int getB(){
            return b;
        }
        
        public void setB(int b){
            this.b = b;
        }
        
        public int add(){
            return a + b;
        }
        
        public int subtract(){
            return a - b;
        }
        
        public int multiply(){
            return a * b;
        }
        
        public double divide(){
            return (double) a / (double) b;
        }
    }
    
    public static class Calculator extends Arithmetic{
        
        public Calculator(int a, int b){
            super(a, b);
        }
    }
} 
`​​``
misty steppeBOT
#

This post has been reserved for your question.

Hey @sharp pasture! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

misty steppeBOT