I've been a bit busy lately so sorry for the delayed answer.
The bouncing off the sides of the screen is done in the pong example for the two of the four edges. You basically only need to copy that part and figure out the formulas for the other two if you need those, too (the collision with the those edges is there but hitting those edges just ends the game, it doesn't bounce the ball of the wall). There is a way to do it with one function, without any special cases (=only one formula would be needed). The problem is that you would need to know vector math to be able to understand it. So I ask you, do you know anything about vector math?
Oh, and checking the collision with the edge of the screen is even easier than bounding box detection. You only need to check if the ball's coordinates are less than zero or over the screen width or height to determine that the ball is colliding with the edges.
I would probably use vectors for the gravity, too (unless you only want it to keep bouncing at the same spot). I would use a vector for the speed of the ball and another vector for the gravity that keeps pulling the ball to the ground.