Sabtu, 18 Juni 2011

Learning Programme "to change the data from a table"

  This time my blog will change the data in the table into a series of programs that will be shown as following table.



In making this program required a combination of 1-dimensional arrays are also two-dimensional array, but it also sought the number of sales and average. These programs include some input that has been set sprt name sales, the amount of goods each month.
 As we know that these things I've discussed in previous blogs, I will focus here only on the display which includes the overall program.

Here's the full program:

1. # Include <cstdlib>
2. # Include <iostream>
3. using namespace std;
4. class sales {
5. public:
6. friend ostream & operator <<(ostream &, & sales);
7. cetak_nama void ();
8. masuk_data void ();
9. void count ();
10. sales ();
11. private:
12. char a [50], b [50], c [50], d [50], e [50];
13. int data [100] [100];
14. int total [50], number [50];
15. double average [50];
16. };
17. sales: sales () {
18. court <<endl <<endl;
19. court <<"#--------------------------------------------- # "<<endl;
20. court <<"# Store: Star White #" <<endl;
21. court <<"# Nn: Desmala Goddess #" <<endl;
22. court <<"# NIM: 10018061 #" <<endl;
23. court <<"#--------------------------------------------- # "<<endl;
24. court <<"Computer sales # #" <<endl;
25. court <<"#--------------------------------------------- # "<<endl;
26. }
27. void the sale:: cetak_nama () {
28. int k = 1;
29. court <<endl <<endl;
30. court <<"Name Sales" <<k <<"="; cin>> a;
31. court <<"Name Sales" <<k +1 <<"="; cin>> b;
32. court <<"Name Sales" <<k +2 <<"="; cin>> c;
33. court <<"Name Sales" <<k +3 <<"="; cin>> d;
34. court <<"Name Sales" <<k +4 <<"="; cin>> e;
35. }
36. void the sale:: masuk_data () {
37. for (int i = 0; i <5; i + +)
38. for (int j = 0; j <5; j + +) {
39. court <<"Enter data to [" <<i +1 <<"] [" <<j +1 <<"]: \ n";
40. cin>> data [i] [j];
41. }
42. }
43. void the sale:: count () {
44. for (int i = 0; i <5; i + +) {
45. total [i] = 0;
46. number [i] = 0;
47. for (int j = 0; j <5; j + +) {
48. total [i] = total [i] + data [i] [j];
49. number [i] = sum [i] + data [j] [i];
50. }}
51. average [0] = 0;
52. number [5] = 0;
53. for (int i = 0; i <5; i + +) {
54. average [i] = (mean [i] + (number [i] / 5));
55. number [i] = sum [5] + amount [i];
56. }
57. }
58. ostream & operator <<(ostream & outs, sales & m) {
59. out <<"---------------------------------------------- --------------------------------------"<< endl;
60. out <<"No \ tNama \ Tjan \ tFeb \ tMar \ tApr \ tMei \ tTotal sales per sales" <<endl;
61. out <<"---------------------------------------------- --------------------------------------"<< endl;
62. out <<"1.";
63. out <<"\ t";
64. for (int i = 0; i <strlen (m.a); i + +) {
65. out <<m.a [i];
66. }
67. out <<"\ t";
68. for (int i = 0; i <5; i + +) {
69. out <<m.data [0] [i] <<"\ t";
70. }
71. out <<m.total [0];
72. out <<endl;
73. out <<"2.";
74. out <<"\ t";
75. for (int i = 0; i <strlen (m.b); i + +) {
76. out <<m.b [i];
77. }
78. out <<"\ t";
79. for (int i = 0; i <5; i + +) {
80. out <<m.data [1] [i] <<"\ t";
81. }
82. out <<m.total [1];
83. out <<endl;
84. out <<"3.";
85. out <<"\ t";
86. for (int i = 0; i <strlen (m.c); i + +) {
87. out <<m.c [i];
88. }
89. out <<"\ t";
90. for (int i = 0; i <5; i + +) {
91. out <<m.data [2] [i] <<"\ t";
92. }
93. out <<m.total [2];
94. out <<endl;
95. out <<"4.";
96. out <<"\ t";
97. for (int i = 0; i <strlen (m.d); i + +) {
98. out <<m.d [i];
99. }
100. out <<"\ t";
101. for (int i = 0; i <5; i + +) {
102. out <<m.data [3] [i] <<"\ t";
103. }
104. out <<m.total [3];
105. out <<endl;
106. out <<"5.";
107. out <<"\ t";
108. for (int i = 0; i <strlen (m.e); i + +) {
109. out <<m.e [i];
110. }
111. out <<"\ t";
112. for (int i = 0; i <5; i + +) {
113. out <<m.data [4] [i] <<"\ t";
114. }
115. out <<m.total [4];
116. out <<"---------------------------------------------- -------------------------------------"<< endl;
117. out <<"\ ttotal \ t";
118. for (int i = 0; i <5; i + +) {
119. out <<m.jumlah [i] <<"\ t";
120. }
121. out <<m.jumlah [5];
122. out <<endl;
123. out <<"\ trata \ t";
124. for (int i = 0; i <5; i + +) {
125. out <<m.rata [i] <<"\ t";
126. }
127. out <<"\ n Total Sales 5 Month";
128. out <<"---------------------------------------------- -------------------------------------"<< endl;
129. }
130. int main (int argc, char * argv [])
131. {
132. z sales;
133. z.cetak_nama ();
134. z.masuk_data ();
135. z.hitung ();
136. cout <<z;
137. system ("PAUSE");
138. return EXIT_SUCCESS;
139. }
 

Tidak ada komentar:

Posting Komentar