at first, plec correct me this one... Code: std::string explanation; // this upper coding char explanation; //after entering void to display 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'; BABY WEAR and others was error, what should i put? plz correct my coding above one first, it it was take long time to solve coding down there. sorrt, bcoz i really dont know.. plz correct me, im running my coding right now with non-stop study, and always refresh this page... this is of mine that full, the new one... Code: #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; } this is the question. no.1, no problem, but no 2, and 3, but also 4. how to exit? but no1, does can repeat or back to menu? bcoz to add many record?
Code: std::string explanation; // this upper coding char explanation; //after entering void to display You need to decide if explanation should be defined as std::string or char. char only stores one character (you need char explanation[20] or some other int if you want to use an array of char), so given that you want to use the Code: explanation='BABY WEAR'; syntax I suspect it should be defined as the first. Your error is probably something along the lines of "explanation: already defined", which you get because you've defined it twice. In future, if you get errors, tell us what they are. It's not always this easy to guess what those errors might be.