I am a beginner to the Japanese language, and I understand that ええ and はい mean the same thing, yes. What I want to know is when to specifically use ええ and はい.
The difference is, はい is polite, formal and safe in every kind of conversations. On the other hand, ええ is mild and polite but lacks sense of modesty and decisiveness compared with はい, and is inappropriate in situations where you need to reply under some authority.
Roughly saying, you don't use ええ when you reply to your sergeant.
Both はい and ええ mean "Yes", and in many cases can be used interchangeably. Additionally, ええ can be used as the equivalent to "yeah" in English, so whenever you think "yeah" is an acceptable answer to someone, you can say ええ, and it won't be out of place.
also, ええ is often used in a a "Yes, but (or Yeah, but)..." statement, because it is slightly less formal than はい, and so it can be used to convey a sense of being somewhat less in agreement.
1: あの映画面白かったね！ ２： ええ、そうだけどコメディよりドラマが好き。 "That movie was great/funny!" "Yeah, but I like dramas more than comedies."
And somewhat related to your question, there is one nuance of using "yes" in Japanese that is sometimes hard for beginners to pick up right away: answering a negative question with an ええ or はい which, unlike English, would mean you are agreeing with the negative question.
Q: 学校に行かないんですか？ A: ええ、気分が悪い、今日。 "You're not going to school?" "Yeah (I'm not), I feel bad/sick today."
From my experience:
Both are used as "yes" as an affirmative response or as a conversation facilitator ("yes, I understand, please go on"). はい is not impolite, but ええ adds more "professional" to the conversation.
- Used especially when communicating in a professional setting is important. For example: someone on a vendor/sales side to a customer/potential customer (or vice versa). Or used by a 専門家 being interviewed on TV about his/her specialty. However, はい in these settings can also be used and isn't necessarily "unprofessional". Depends on preference.
- All other situations. When in doubt, はい can be used.