Nice code. You forgot to use CODE tags around it though (formatted code is important enough that this forum has made it a rule.)
You dumped a bunch of unformatted code here, and your assignment. Well done. Now was there a question you had?
The midterm is approaching and I dont have enough time.
Sorry to hear that. Hope you finish the assignment on time.
Moreover, watch your reply which seems like an accusation.
Seems like? Definitely was.
If you had worked on code already, your first post would have had the following information: language you wanted to use, the code you already had written, OS, compiler. Then you would have stated what problem you were facing in writing your code, noting what you expected, and what you actually observed. You would have then told us how you tried to resolve this problem, and how they failed.
Your thread title is poorly named, and you have been holding back key information. If you are wondering why you are getting this kind of a response, you need to read
http://www.catb.org/~esr/faqs/smart-questions.html. Seriously, read that.
As much as we're willing to help, we hold firmly to the idea of "assist" not "do someone else's work for them".