so, this is my coding.

#include<iostream.h>
#include<fstream.h>
#include<stdlib.h>
#include<iomanip.h>
    using std::cout;
    using std::cin;
    using std::endl;
    
    struct menu
	typedef struct menu RECORD;
	void addRecord(RECORD input[], int arraycounter);
	void printRecord( input[]);	
	void printAllRecord( input[]);
	
int main()
{
    fstream submit;
	submit.open("D:jualan.dat",ios::out);
	
    {
    int menuEnter;
    int arraycounter=0;
    
    do
    {
    cout<<"\tFamily Outfit Shop"<<endl;
    cout<<"\t    MAIN MENU"<<endl;
    cout<<"\t-------------------"<<endl;
    cout<<" 1 = Add a record\n";
    cout<<" 2 = Displays sales report for a category\n";
    cout<<" 3 = Displays sales report for all category\n";
    cout<<" 4 = Exit";
    cout<<"\nEnter Menu Number : ";
    cin>> menuEnter;
     
    if(menuEnter == 1 )
    addRecord;
    else if (menuEnter == 2 )
    printRecord;
    else if (menuEnter == 3)
    printAllRecord;
    } while (menuEnter!=4);
    return 0;
    }
     
	void addRecord(RECORD input[], int arraycounter);
    {
    char codeCate; // code category
    char codeNumbCate;  // code number category

    cout<<"Enter code category : \n";
    cin>>input[arraycounter].codeCate;
    cout<<"Enter code number of category : \n";
    cin>>input[arraycounter].codeNumbCate;
    arraycounter++;
    }
     
	void printRecord(RECORD input[]);
    {
     
    cout<<"SALES REPORT FOR "<<explanation<<endl;
    cout<<"\nItem Number\t\tPrice" << endl;
    cout<<"------------------------------"<<endl;
    cout<<codeCate<<"\t\t"<<price<<endl;
    cout<<"------------------------------"<<endl;
    cout<<"Total Sales\t\t"<<totalSales<<endl;
    cout<<endl;
    }

	void printAllRecord(RECORD input[]);
    {
    cout<<"SALES REPORT FOR ALL CATEGORIES"<<endl;
    cout<<"\nCategory\t\tSales" << endl;
    cout<<"------------------------------"<<endl;
    cout<<explation<<"\t\t"<<price<<endl;
    cout<<"------------------------------"<<endl;
    cout<<"Total Sales\t\t"<<totalSales<<endl;
    cout<<endl;
    }
}

error? yes, it is, bcoz i still did not finish it...
still, i'm running doing this coding and keep doing it, but i need help.
i keep doing mine, still someone must help me.
i will post update for my new coding...

there is the question. sorry bcoz it is long.


Family Outfit Shop decided to create a computerized system to maintain the shop inventory. The shop sells variety of garments and the garments are categorized to a particular group. Each category is given a code and the explanation for each code is given bellow.

CODE | EXPLANATION
A | baby wear
B | children wear
C | ladies wear
D | menswear

You as a programmer are required to write a program which contains a menu as bellow:

Family Outfit Shop
MAIN MENU
1)Add a record
2)Display sales report for a category
3)Display sales report for all category
4)Exit

Guideline
The program should give the user an option to choose any sub menu and it would only stop when the user choose the Exit sub menu.

1)Add a record
This sub menu will add a sales record for a particular garment into a file name jualan.dat. Each record consists of three fields which are item number, item code and price. The user may add more than one record at a time. You can use a sentinel value to control the loop. Assumed that file jualan.dat already exists. Example of file jualan.dat is shown as bellow:
A101= A =10.00
B101= B = 12.00
A102 =A= 5.00
B105= B = 17.00
C103 =C= 40.00
D101 =D = 15.00
B104 =B =20.00

2)Display sales report for a category
In this sub menu the sales report of a particular category will be displayed. The category shall be chosen by the user.

SALES REPORT FOR BABY WEAR
Item Number | Price
A101 | 10.00
A102 | 5.00
Total Sales | 15.00

3)Display sales report for all category
In this sub menu the sales report for all the categories will be displayed.

SALES REPORT FOR ALL CATEGORIES
Category Sales
Baby wear 15.00
Children wear 49.00
Ladies wear 40.00
Menswear 15.00
Total Sales 119.00

4)Exit
End of program.

so, how / where to put claculation in there?
i means, in record or print...
i try....
and also, how to display multiple of item number?

The first problem I see is that you need to surround the structure with { and } braces and put the typedef statement outside the structure

typedef struct menu RECORD;
struct menu
{
    void addRecord(RECORD input[], int arraycounter);
    void printRecord( input[]);	
    void printAllRecord( input[]);
};

The first problem I see is that you need to surround the structure with { and } braces and put the typedef statement outside the structure

typedef struct menu RECORD;
struct menu
{
    void addRecord(RECORD input[], int arraycounter);
    void printRecord( input[]);	
    void printAllRecord( input[]);
};

ok, that qould be help...

seriously anybody?

Ok, here is the completed program. But don't turn it in because your teacher will know that you didn't write it.

#include <ios>
#include <istream>
#include <limits>
#include<iostream>
#include<fstream>
#include <string>
#include <vector>
#include <algorithm>
using std::cin;
using std::cout;
using std::string;

// clothing codes
struct codes
{
	char code;
	const char* explanation;
	float total_sales;
};
codes CODES[] = { 'A',"baby wear",0.0F,
	'B',"children wear",0.0F,
	'C',"ladies wear",0.0F,
	'D',"mens wear",0.0F,
	0,NULL,0.0F
};

struct RECORD
{
	int item_number;
	char code;
	float price;
};

const string filename = "jualan.dat";
int menu();
void AddRecord();
void ShowByCategory();
void ShowAll();
// This function from Naru's tutorial posted on DaniWeb
__inline void ignore_line ( std::istream& in )
{
	in.clear();
	in.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
}


int main()
{
	int select;
	while( (select = menu()) < 4 )
	{
		switch(select)
		{
		case 1: // add a record
			AddRecord();
			break;
		case 2: //Display sales report for a category
			ShowByCategory();
			break;
		case 3: // Display sales report for all category
			ShowAll();
			break;
		};

	}
}

int menu()
{
	cout << "Family Outfit Shop\n"
		<< "MAIN MENU\n\n"
		<< "1)Add a record\n"
		<< "2)Display sales report for a category\n"
		<< "3)Display sales report for all category\n"
		<< "4)Exit\n";
	string input;
	bool failed;
	int select = 0;
	do {
		failed = false;
		cin >> input;
		for(size_t i = 0; i < input.length(); i++)
		{
			if( !isdigit(input[i]) )
			{
				cout << "Numeric digits only -- please try again.\n";
				failed = true;
				break;
			}
		}
		if( failed == false)
		{
			select = atoi(input.c_str());
			if( select < 1 || select > 4 )
			{
				cout << "Select a number between 1 and 4\n";
				failed = true;
			}
		}
		cout.clear();
		ignore_line(cin);
	} while( failed == true );
	return select;
}

void AddRecord()
{
	std::ofstream out(filename.c_str(),std::ios::binary);
	bool done = false;
	string answer;
	while( done == false)
	{
		RECORD r;
		cout << "Enter item number\n";
		cin >> r.item_number;
		ignore_line(cin);
		cout << "Enter code (A, B, C or D)\n";
		cin >> r.code;
		r.code = toupper(r.code);
		ignore_line(cin);
		cout << "Enter price\n";
		cin >> r.price;
		ignore_line(cin);
		out.seekp(0,std::ios::end);
		out.write((char *)&r,sizeof(RECORD));
		cout << "\nEnter another record? (Y/N)\n";
		cin >> answer;
		ignore_line(cin);
		if( answer == "N" || answer == "n")
			done = true;
	} while(done == false);
}

// This function is called by std::sort to sort a std::vector<RECORD> 
// in ascending order by item number.
bool compare(const RECORD& r1,const RECORD& r2)
{
	return r1.item_number < r2.item_number ? true : false;

}

void ShowByCategory()
{
	string category;
	bool done = false;
	while(done == false)
	{
		cout << "Please enter category (A, B, C or D)\n";
		cin >> category;
		std::transform(category.begin(),category.end(),category.begin(),toupper);
		switch(category[0])
		{
		case 'A': case 'B': case 'C': case 'D':
			done = true;
			break;
		default:
			cout << "You idot, try again\n";
			break;
		}
	}
	ignore_line(cin);
	std::ifstream in(filename.c_str(),std::ios::binary);
	std::vector<RECORD> theList;
	RECORD r;
	while( in.read((char *)&r, sizeof(RECORD)) )
	{
		if( r.code == category[0])
			theList.push_back(r);
	}
	in.close();
	std::sort(theList.begin(),theList.end(),compare);
	cout << "SALES REPORT FOR ";
	for(int i = 0; CODES[i].code != 0; i++)
	{
		if( CODES[i].code == category[0] )
		{
			cout << CODES[i].explanation << '\n';
			break;
		}
	}
	cout << "Item Number" << '\t' << "Price\n";
	for(unsigned i = 0; i < theList.size(); i++)
	{
		cout << theList[i].item_number << '\t' << theList[i].price << '\n';
	}
	cout << "\n\n";

}


void ShowAll()
{
	std::ifstream in(filename.c_str(),std::ios::binary);
	RECORD r;
	for(int i = 0; CODES[i].code != 0; i++)
	{
		CODES[i].total_sales = 0.0F;
	}
	while( in.read((char *)&r, sizeof(RECORD)) )
	{
		for(int i = 0; CODES[i].code != 0; i++)
		{
			if( CODES[i].code == r.code )
			{
				CODES[i].total_sales += r.price;
				break;
			}
		}
	}
	in.close();
	cout << "SALES REPORT FOR ALL CATEGORIES\n"
	<< "Category" << '\t' << "Sales\n";
	for(int i = 0; CODES[i].code != 0; i++)
	{
		cout << CODES[i].explanation << '\t' << CODES[i].total_sales << '\n';
	}
	cout << "\n\n";
}

@Ancient Dragon, this my new coding, means the new one after above there...

#include<iostream>
#include<fstream>
#include<cstdlib>
#include<iomanip>
#include<string>

using std::cout;
using std::cin;
using std::endl;

struct RECORD
{
    std::string item_code;
    std::string item_number;
	std::string explanation;
    double price;
}input[10000];

void addRecord(RECORD input[], int &arraycounter);
void printRecord(RECORD input[]);
void printAllRecord(RECORD input[]);

int main()
{
    std::fstream submit;
    submit.open("jualan.dat",std::ios::in);
    submit.seekg(0, std::ios::beg);
    int arraycounter=0;

    do
    {
        submit>>input[arraycounter].item_number>>input[arraycounter].item_code>>input[arraycounter].price;
        arraycounter++;
    }
	
	while(submit.good());
    submit.close();
    arraycounter--;
    {
    	int menuEnter;
		do
			{
        		cout<<"\tFamily Outfit Shop"<<endl;
       			cout<<"\t    MAIN MENU"<<endl;
        		cout<<"\t-------------------"<<endl;
       			cout<<" 1 = Add a record\n";
				cout<<" 2 = Displays sales report for a category\n";
				cout<<" 3 = Displays sales report for all categories\n";
				cout<<" 4 = Exit";
				cout<<"\nEnter Menu Number : ";
				cin>>menuEnter;

        		if(menuEnter==1)
            		addRecord(input, arraycounter);
				else if (menuEnter==2)
            		printRecord(input);
        		else if (menuEnter==3)
            		printAllRecord(input);
			}
				while (menuEnter!=4);
    	return 0;
    }
    
   	void addRecord(RECORD input[], int arraycounter);
   	{
		char item_code; // code category
		char item_number;  // code number category

		cout<<"Enter code category : \n";
		cin>>input[arraycounter].item_code;
		cout<<"Enter code number of category : \n";
		cin>>input[arraycounter].item_number;
		arraycounter++;
   	}
    
    void printRecord(RECORD input[]);
    {
    	char item_code, item_number;
    	char explanation;
    	float price, total_sales;
    	
    	cout<<"Please enter category code : "<<endl;
    	cin>>item_code;
    		if(item_code=='A')
				explanation==BABY WEAR;
			else if(item_code=='B')
				explanation='CHILDREN WEAR';
			else if(item_code=='A')
				explanation='LADIES WEAR';
			else if(item_code=='A')
				explanation='MENSWEAR';

    	cout<<"SALES REPORT FOR "<<explanation<<endl;
		cout<<"\nItem Number\t\tPrice" << endl;
		cout<<"------------------------------"<<endl;
		cout<<item_code<<item_number<<"\t\t"<<price<<endl;
		cout<<"------------------------------"<<endl;
		cout<<"Total Sales\t\t"<<total_sales<<endl;
		cout<<endl;

switch(item_code)
{
	case'A':
	if(item_number==101)
	{
		price=10.00;
	}
	if(item_number==102)
	{
		price=5.00;
	}
	break;
	
	case'B':
	if(item_number==101)
	{
		price=12.00;
	}
	if(item_number==104)
	{
		price=20.00;
	}
	if(item_number==105)
	{
		price=20.00;
	}
	break;
	
	case'C':
	if(item_number==103)
	{
		price=12.00;
	}
	break;
	
	case'D':
	if(item_number==101)
	{
		price=12.00;
	}
	break;
}
    }
    
    void printAllRecord(RECORD input[]);
    {
		cout<<"SALES REPORT FOR ALL CATEGORIES"<<endl;
		cout<<"\nCategory\t\tSales" << endl;
		cout<<"------------------------------"<<endl;
		cout<<explanation<<"\t\t"<<price<<endl;
		cout<<"------------------------------"<<endl;
		cout<<"Total Sales\t\t"<<totalSales<<endl;
		cout<<endl;
}

but i try run ur coding, ok, it ok...

but still its REALLY HELP...

but yet, still, i need to edit it...

EDITING A LOT...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.