Help me to solve my assignment

Create a program to ask for the number of sales per store and display barchart report in the form of the sale. For example:

Sales Report
-----------------------------------------------
(each x represents Rp. 1.000.000, -)
Toko Grogol: xxxxx
Toko Tomang: xxxxxxxxx
Toko Puri: xxxxxxx
Toko Slipi: xxxx
Toko Kopro: xxxxxxxx

That is the question, and this is my program, but it doesn't work at all T_T, can someone help me?

#include <iostream>
using namespace std;

void main ()
{
int TG,TT,TP,TS,TK,LPG,LPT,LPP,LPS,LPK;

cout << " Banyaknya penjualan setiap toko : " << endl;

for (TG=1;TG<=5;TG++)
{cin >> LPG;
cout << " " << LPG << " " << TG << endl;}
for (TT=1;TT<=9;TT++)
{cin >> LPT;
cout << " " << LPT << " " << TT << endl;}
for (TP=1;TP<=7;TP++)
{cin >> LPP;
cout << " " << LPP << " " << TP << endl;}
for (TS=1;TS<=4;TS++)
{cin >> LPS;
cout << " " << LPS << " " << TS << endl;}
for (TK=1;TK<=8;TK++)
{cin >> LPK;
cout << " " << LPK << " " << TK << endl;}

system ( " Pause " );
}


First of all, explain what Rp is. Next of all, you might want to organize your code in a more tidier way.
E.g:

for ( TS=1;TS<=4;TS++)
{
cin >> LPS;
}

Last of all, explain what all your variables do, and do not type in foreign languages. Most of the people here speak English, not other languages.

P.S Edit: Do not use void main, use int main() instead.
Last edited on
ok
Rp is currency, Rupiah
The variable is for decide the amount of each "toko" example
TG is for LPG

i tried so hard that you all can understood my english, sorry for my bad english thank you

i don't know how to build a barchart using c++
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
using namespace std;
void setX(int x);
int main()
{
int LPG,LPT,LPP,LPS,LPK;
cout << "Enter the money earnt for LPG" << endl;
cin >> LPG;
cout << "Enter the money earnt for LPT" << endl;
cin >> LPT;
cout << "Enter the money earnt for LPP" << endl;
cin >> LPP;
cout << "Enter the money earnt for LPS" << endl;
cin >> LPS;
cout << "Enter the money earnt for LPK" << endl;
cin >> LPK;
cout << "\x1b[2J\x1b[1;1H" << flush;
cout << "Sales Report\n"
     << "--------------------------\n"
     << "(each x represents Rp. 1.000.000, -)\n"
     << "Toko Grogol: ";
setX(LPG);
cout << "\nToko Tomang: ";
setX(LPT);
cout << "\nToko Puri: ";
setX(LPP);
cout << "\nToko Slipi: ";
setX(LPS);
cout << "\nToko Kopro: ";
setX(LPK);
}
void setX(int x)
{
    int z;
    z = x;
    while(z != 0)
    {
        if(z <= 0)
        {
            break;
        }else
        {
        cout << "x";
        z-= 1000000;
        }
    }
}


Tell me if it works.
WOW
it works, but why after i input all the number, the program actually end, and then why you use int and void main, can you explain it to me
thanks before ^^
What do you mean program actually end? Every program is supposed to end after doing what they're supposed to.

And, int main is standard for all compilers of C++.

void setX(int x) is the function of printing out the bar graph because it would be a mess if I did it manually.
i mean before the end, i usually have getch(); or System("pause"); to stop the program, so my teacher can see it, but in your program when i add it, the program didn't pause, then when it didn't pause, how can my teacher see my assignment, thank you before ^^
Now that you aren't using void main(), you should type either return 0; or system("PAUSE");

Because I am writing the program in codeblocks and if I do not add return 0, it will automatically add for me. P.S : I am lazy
sorry for my long reply
ahhh, i get it, thank you ^^
Topic archived. No new replies allowed.