Need help with few programms.

Jun 16, 2015 at 12:43pm
Hello, I am a student and I am learning programming with internet technologies.
Programming was my weakest subject. I have a debt in one of the subjects from last year. As I forgot mostly everything it's really hard for me to fix the debt.

I got two tasks to fix it and I would like to ask if someone could do it for me. I need to have it done now.

1. Find a text of 10000 words, count letters of each word, save the words and letters in map type container they need to be lined from shortest to longest word.
The results than have to be showed in a txt file. Find 100 most often used words. Use iostream, string and map libraries. Has to be done in OOP style.

2.Calculated function y = cos ( x ) values ​​and to output to a file. X varies between 59 ° 59'30 '' to 60 ° 00'30 '' after one second. X value derived sexagesimal format. Y value to put 10 decimal places . Task Has to be done in OOP style.


I know I have to do stuff like that by myself. But for me c++ is like hitting a brick wall. We have many subjects but this one is hardest for me. So I am asking for help out of desperation.
Last edited on Jun 16, 2015 at 12:45pm
Jun 16, 2015 at 1:46pm
Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.
Jun 16, 2015 at 1:56pm
Divide and conquer.
Separate your task into smaller subtasks and engage them one by one.
I will show example of such subtasks for your first assigment (I'll remove some parts which I do not completely understand or which are not used later)

Find a text of 10000 words, count letters of each word, save the words and letters in map type container they need to be lined from shortest to longest word.
The results than have to be showed in a txt file. Find 100 most often used words. Use iostream, string and map libraries. Has to be done in OOP style.


So problems are:
1) Open input file. Decide if file name would be hardcoded, received as command line parameter or entered by user. Depending on what you choose, this task can spawn subtasks. I will assume that name is hardcoded.
2) Read words. It moght be easy or hard depending on file contents. I will assume that it is just bunch of words separated by whitespace, no punctuation.
3) Save the worlds in a map. You need to find most frequent words, so word will be the key and amount of times word is encountered will be value. As you have a requirement: "they need to be lined from shortest to longest word", then you need to provide your own comparison function which does that which spawns a subtask:
    a) Create a comparison function. It needs to sort words first by length, then lexicographically (default sorting).
4) Find 100 most used words. There are differnt ways to do that, try to think one yourself.
5) Open output file. Again, I will assume that filename is hardcoded.
6) Write to output file. First decide how your output will look like. Then code it. Outputting in file is no different from outputting on screen actually.

With these smaller tasks it should be easier for you to think and search reference for hints. If something still looks complex to you, divide it further.
Ask if you have concrete questions or problems regarding your actual code.
Topic archived. No new replies allowed.