Sales bar chart using loops

For my hw assignement we have to have the user input 5 different values for 5 days of sale. And then program a bargraph using asterisk*** in rows equaling the values from the user where *= 100$

here is my code so far, im in desperate need of a little guidance! ty







#include <iostream>

using namespace std;


int main()
{

int stores; //Number of Stores

//Get the number of stores.
cout << "For how many stores do you have sales figures? ";
cin >> stores;



//get the sales for each store.
for (int count = 1; count <= stores; count++)

{

double sales;
cout << "Enter today's sales for day " << count << ": ";
cin >> sales;

}











return 0;
}
anybody?
closed account (zb0S216C)
Here's some descriptive code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Create_Chart( Parameters... );

Main_Entry_Point( )
{
    Unsigned_Integer_Array Input[3] = { 0 };

    for( Char I( 0 ); I < 3; ++I )
        Std_Cin >> Integer_ArrayI;

    Char_Ptr_to_Ptr = Create_Chart( 3_Rows );

    for( Char I( 0 ); I < 3; ++I )
    {
        Char_Ptr_to_PtrI = New_Char_Array[( InputI / 100 )];
        for( Char J( 0 ); J < ( InputI / 100 ); ++J )
            Char_Ptr_to_PtrIJ = '#';
    }

    Print the chart...

    Release the memory...
    Return from Main_Entry_Point( )....
}

Create_Chart( )
{
    Content...
}


Wazzak
Last edited on
Well, you're going to have a big problem when trying to make your bar graph. You ended up with 1 store variable number, not 5 values for 5 stores. For that, you needed to declare the int stores; as int stores[5]; That will give a place to store 5 different inputs, starting with stores[0]; and ending with stores[4];. If you need more than 5 stores, make the 5 a larger number, but you must do that at the creation of your program. You cannot make an array afterwards. Well, technically you can, but for a beginner, not so easily. You deal with pointers, etc. Anyway, in your loop, it would be
1
2
cin >> sales;
stores[count] = sales;
And you should declare your doubles sales after main(), not in the loop. You most likely get an error saying that the sales variable, already exists.
Hope this gets you started.
i reqrote it like this, how can i get that for * statement to work right representing the input validation /100?



#include <iostream>

using namespace std;


int main()
{

int store1;
int store2;
int store3;
int store4;
int store5;


cout << "daily income for store1:";
cin >> store1;
for( store1; store1 == 1000; ++store1 )
{
cout << "*";
}

cout << "daily income for store2:";
cin >> store2;

cout << "daily income for store3:";
cin >> store3;

cout << "daily income for store4:";
cin >> store4;

cout << "daily income for store5:";
cin >> store5;






return 0;
}
Please help. I need this assignment bad!
Topic archived. No new replies allowed.