This is a computer sales program that will display the data table the number of sales to sell computers, which occurred in a computer store.
Here is the source code "How are the sales selling the computer".
#include<iostream>
#include<conio.h>
using namespace std;
class Sales {
public :
Sales();
void print_selling();
void print_sales();
void sum_selling_sales();
void sum_selling_month();
void search_max_selling(int &temp1, int &temp2);
private :
int penjualan[5][5];
char *sales_name[5];
int total_sales[5];
int total_month[5];
};
void Sales::print_selling(){
cout << "Data of selling in the Computer shop (Monthly and Sales) : " << endl;
for (int i=0; i < 5; i++) {
for (int j=0; j < 5; j++) {
cout << penjualan[i][j] << "\t";
}
cout << endl;
}
}
void Sales::print_sales() {
cout << "Name of sales : " << endl;
for (int i=0; i < 5; i++) {
cout << sales_name[i] << "\t";
cout << endl;
}
}
Sales::Sales() {
penjualan[0][0] = 34;
penjualan[0][1] = 15;
penjualan[0][2] = 100;
penjualan[0][3] = 22;
penjualan[0][4] = 55;
penjualan[1][0] = 12;
penjualan[1][1] = 27;
penjualan[1][2] = 10;
penjualan[1][3] = 45;
penjualan[1][4] = 12;
penjualan[2][0] = 6;
penjualan[2][1] = 30;
penjualan[2][2] = 20;
penjualan[2][3] = 15;
penjualan[2][4] = 70;
penjualan[3][0] = 50;
penjualan[3][1] = 20;
penjualan[3][2] = 34;
penjualan[3][3] = 70;
penjualan[3][4] = 24;
penjualan[4][0] = 72;
penjualan[4][1] = 40;
penjualan[4][2] = 62;
penjualan[4][3] = 18;
penjualan[4][4] = 46;
sales_name[0] = "Agus";
sales_name[1] = "Bambang";
sales_name[2] = "Catur";
sales_name[3] = "Dita";
sales_name[4] = "Erna";
}
void Sales::sum_selling_sales() {
cout << "Total selling (Per Sales) : " << endl;
for (int i=0; i < 5; i++) {
total_sales[i] = 0;
for (int j=0; j < 5; j++) {
total_sales[i] += penjualan[i][j];
}
cout << total_sales[i] << endl;
}
}
void Sales::sum_selling_month() {
float rata[5];
cout << "Total selling (Monthly) : " << endl;
for (int j=0; j < 5; j++) {
total_month[j] = 0;
for (int i=0; i < 5; i++) {
total_month[j] += penjualan[i][j];
}
rata[j] = total_month[j]/ 5.0;
cout << total_month[j] << "\t" << rata[j] << endl;
}
}
void Sales::search_max_selling(int &temp1, int &temp2) {
int i, j, max = penjualan[0][0];
for (i = 0; i < 5; i++)
for (j = 0; j < 5; j++)
if (penjualan[i][j] > max)
{ max = penjualan[i][j];
temp1 = i;
temp2 = j;
}
cout << "Top selling is : " << max << " at month : " << temp2 << endl;
cout << "And sales name is : " << sales_name[temp1] << endl;
}
int main(int argc, char *argv[])
{
int a, b;
Sales X;
X.print_selling();
X.print_sales();
X.sum_selling_sales();
X.sum_selling_month();
X.search_max_selling(a,b);
system("PAUSE");
return EXIT_SUCCESS;
}
Tidak ada komentar:
Posting Komentar