It still not working and it seems to be worse than before in terms of how long the ball is supposed to travel after a certain force is used on it. Also it is not going in the right direction. Did I miss anything?

public boolean travel(double dt) {

        if (!ballMoved)
            return false;
           
        //for a 2D space the velocity operations is treated as a vector
        double velocity = Math.sqrt(vx * vx + vy * vy);
       
        //BACKUP the previous velocity value
        double vxs = vx;
        double vys = vy;
       
        if (velocity != 0. && !inHole)
        {           
            if (velocity < 0.)
            {
                vx = 0.;
                vy = 0.;
            }
            else
            {
              //CALCULATE THE NEW VELOCITY
                vx -= a * dt;               
                vy -= a * dt;
            }
        }
        //CALCULATE THE DISPLACEMENT
        x += (vxs+vx) * dt/2;
        y += (vys+vy) * dt/2;

        if(isWithinLimits(x, y))
          { /*no action taken*/ }
        else if(inHole)
          {
                vx = 0.;
                vy = 0.;
          }
        //if the x and y coordinate value are larger than the limits
        //which are the table boundary
        else
            changeDirection();