How can you calculate the number of electrons in an atom?
In practical terms, it isn't really possible with our current level of technology to count the electrons in a single atom. However, there are some theoretical and experimental alternatives.
The most basic answer is that we can hypothesize that a neutral atom will have an equal number of protons and electrons. In this situation we're envisioning an atom that is completely isolated and unable to contact other atoms or electrons. In these circumstances, we assume that the atom would neutralize its own positive charges with an equal number of electrons, and in practice this is generally what we observe for the noble gases.
Much of chemistry is based on what subsequently happens when atoms are allowed to come in contact with each other. The various differences in electromagnetic attraction between different atoms and their constituent electrons and protons causes a variety of possibilities to exist for most circumstances. Thus, at any given time, it may be difficult or impossible to determine the electrons present in any average piece of matter, due to our technology being unable to isolate things on this scale.
There are several exemptions; for example, the aforementioned noble gases, which can often be considered to exist in their neutral state, and therefore have a fixed number of electrons. Others include the alpha particle, which is just a helium nucleus and therefore has 0 electrons, and also the hydrogen ion, which is just a proton and would also have 0 electrons. In most other circumstances, you would have to do some basic math using a periodic table and a knowledge of bonding structures to tally or estimate the electrons present on paper, let alone in reality.