Hi, my tutor has set a coursework for us and i need help with a small part of the coursework.

A small program where some one tests new programmes or you can call it benchmarking :)

Basically there are 20 programmes and he sets them each of them mark out of 100.

The program should also display a histogram and each star represents a mark.

0-29 ***
30-39 *****
40-69 ********
70-100 ****

something like that.

Any small help with coding and the layout will be greatly appreciated :)

Could you perhaps ask a specific question? Right now it looks like you're asking for some charitable soul to do your homework.

Could you perhaps ask a specific question? Right now it looks like you're asking for some charitable soul to do your homework.

lol that's not what i'm asking :)

What i'm asking is this, when the person whos running the benchmarks and give them a mark, in the histogram it should show up what mark has been given for e.g. marks between 0-29.

That's all mate :)

>lol that's not what i'm asking
That's good.

What i'm asking is this, when the person whos running the benchmarks and give them a mark, in the histogram it should show up what mark has been given for e.g. marks between 0-29.

Okay, and what about that don't you understand? Have you tried anything? The only way to answer your "question" right now is to hold your hand through the whole thing, which is effectively the same as doing it for you.

Edited 5 Years Ago by Narue: n/a

>lol that's not what i'm asking
That's good.


Okay, and what about that don't you understand? Have you tried anything? The only way to answer your "question" right now is to hold your hand through the whole thing, which is effectively the same as doing it for you.

Hehe, I guess i'm not being specific ;)

What i'm asking is, what syntax/codes you use for the cin like "cin>>grade" when the grade is given like 29, 29 should show up in the histogram.

That's the part i don't understand is how will a star show up in the histogram if a grade has been given for the benchmark.

Sorry that I'm not that good, it's because my C++ lecturer has been away since the 2nd week of start of uni and we haven't learn anything on C++.

Thanks for the reply mate anything helps.

A histogram is a graph of frequency. You add a star for each grade within the range on that row. For example, here's a histogram of characters typed:

#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>

int main()
{
    std::map<char, int> hist_base;
    char ch;

    // Build the count of each character
    while (std::cin.get(ch))
        ++hist_base[ch];

    std::map<char, int>::const_iterator it = hist_base.begin();
    std::map<char, int>::const_iterator end = hist_base.end();

    // Print a histogram for the counts
    for (; it != end; ++it) {
        if (std::isprint(it->first))
            std::cout<< std::setw(2) <<'\''<< it->first <<'\'';
        else
            std::cout<< std::setw(4) << static_cast<int>(it->first);

        std::cout<<": "<< std::string(it->second, '*') <<'\n';
    }
}

A histogram is a graph of frequency. You add a star for each grade within the range on that row. For example, here's a histogram of characters typed:

#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>

int main()
{
    std::map<char, int> hist_base;
    char ch;

    // Build the count of each character
    while (std::cin.get(ch))
        ++hist_base[ch];

    std::map<char, int>::const_iterator it = hist_base.begin();
    std::map<char, int>::const_iterator end = hist_base.end();

    // Print a histogram for the counts
    for (; it != end; ++it) {
        if (std::isprint(it->first))
            std::cout<< std::setw(2) <<'\''<< it->first <<'\'';
        else
            std::cout<< std::setw(4) << static_cast<int>(it->first);

        std::cout<<": "<< std::string(it->second, '*') <<'\n';
    }
}

Thanks for the help friend, i'll use yours as a example and make my own one with my own perenthesis :)

Oh might i ask, which IDE are you using?

>Oh might i ask, which IDE are you using?
I use several, depending on which operating system and compiler I'm targeting.

>Oh might i ask, which IDE are you using?
I use several, depending on which operating system and compiler I'm targeting.

Great, so if you're targeting Linux which one would you use?

>Great, so if you're targeting Linux which one would you use?
If you want me to recommend an IDE for you, let's not beat around the bush with "what do you use on the platform that happens to be the same as mine?" questions. Code::Blocks would be a good start as it's relatively light weight. Another decent starter IDE is CodeLite. Both are cross-platform.

>Great, so if you're targeting Linux which one would you use?
If you want me to recommend an IDE for you, let's not beat around the bush with "what do you use on the platform that happens to be the same as mine?" questions. Code::Blocks would be a good start as it's relatively light weight. Another decent starter IDE is CodeLite. Both are cross-platform.

Thanks, I'll stop bothering you now :)

This article has been dead for over six months. Start a new discussion instead.