URGENT ... VERTICAL BAR GRAPH IN C++

Hello,

I need Help with a Code....

I need to do a Vertical Bar Graph that looks like this
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main ()
{


this are the variables

I want a Vertical Bar Graph that can print something like this.

y10---*
y9----*
y8----*------*
y7----*------*
y6----*------*-------*
y5----*------*-------*
y4----*------*-------*
y3----*------*-------*
y2----*------*-------*
y1----*------*-------*
y0----*------*-------*

Can someone HELP ME with a Code for this.

PLEASE..!
Last edited on
That is such an abuse of the console. *sniff*

Have you considered using a for loop to print either whitespaces or bar segments depending on if the loop is on a certain iteration larger than max - itemnum?

-Albatross
Wait wait wait. Your teacher told you to make a bar graph in C++ with the consule? Or is this you talking a big game and needing a bail out? I have no problem with the later, and I'll gladly help out either way. But I'm curious to know if your teacher is honestly that backward.

EDIT: In the later case, you needing a bail out, I'd show you how to do this in SFML.
Last edited on
You could make a drawbar() function like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
void drawsegment(int size)
{
        /* ??? */
}

void drawbar(std::string barname, int blocks, int trucks, int dolls)
{
        std::cout << barname << '|';
        drawsegment(blocks);
        drawsegment(trucks);
        drawsegment(dolls);
        std::cout << std::endl;
}


You can write the drawsegment function yourself. Then I think that would do what you're trying to do.
Last edited on
Well actually it wasnt my teacher, I dont have a teacher.... Im just learning C++ from zero and found a some papers to start doing a program in a bus tried to do it but it is to difficult for me..

Thank you anyway!
Dinorah wrote:
Well actually it wasnt my teacher, I dont have a teacher.... Im just learning C++ from zero and found a some papers to start doing a program in a bus tried to do it but it is to difficult for me..


Uhhhh. then why the big URGENT!!!?

But good for you, if you aren't lying, if you are, shame on you.
Topic archived. No new replies allowed.