A camera with a pinhole has a focal length 10 cm. The height of a tree is 5 meters. How large is the picture of a tree on the inside surface if the tree is 14 meters from the camera?

Is my calculation correct?

Code:

f = 10; //cm
Z = 14 * 100 //cm
X = 0;
Y = 500;
x = -f * (X / Z);
y = -f * (Y / Z);
y + x // Size of a picture

And why do we don't use camera obscura any more? What is the benefit of camera's with lenses?