#include <iostream> #include <fstream>using namespace std;const int m=100; Define constants MClass Bankstore{private:int Banknumber; Bank account Char name[20]; Name Double Inputprice; Deposit amount int income; Income amount int charge; Expense amount int tradeamount; Current transaction (or Transact-business) Number of int amount;public:void Input (); int input_2 (); void Dig (); void Changemessage (); void Search_banknumber () void Search_name (); void Show (); void DeleteAccount ();} People[m];void bankstore::input () {int i,n;cout<< "number of customers who have opened an account:" Cin>>amount;cout<<endl;for (i=0;i <amount;i++) {cout<< "This is the section" << (i+1) << "Customer Information" <<endl;people[i].banknumber=i+1;cout< < "customer's name:";cin>>people[i].name;cout<< "lump sum deposit:";cin>>people[i].inputprice;cout<< "revenue : ";cin>>people[i].income;cout<<" expenditure: "; cin>>people[i].charge;cout<<endl;} cout<< "\ nthe information for these customers is as follows:" <<endl;for (i=0;i<amount;i++) {cout<< "Customer Information:" <<people[i]. banknumber<<ends;cout<< "Customer's name:" <<people[i].name<<ends;cout<< "Lump sum deposit:" <<people[i].inputprice<<ends;cout<< "Revenue:" <<people [i].income<<ends;cout<< "expenditure:" <<PEOPLE[I].CHARGE<<ENDS<<ENDL;} Ofstream os ("People.txt", ios_base::out|ios_base::binary); Create, open file for (n=0;n<amount;n++) {Os.write (reinterpret_cast<char*> (& (People[n])), sizeof (Bankstore)); Export file}os.close (); Close file}int bankstore::input_2 ()//file read in {int i,n;ifstream is ("People.txt", Ios_base::in|ios_base::binary), if (!is) { cout<< "Open failed" <<endl;return 0;} For (I=0;is.read (Reinterpret_cast<char *> (people+i), sizeof (Bankstore)); i++) amount=i;cout<< " Information for customers currently in operation: "<<endl;for (n=0;n<amount;n++) {cout<<" Customer Information: "<<people[i].banknumber<< ends;cout<< "Customer's name:" <<people[i].name<<ends;cout<< "lump sum deposit: <<people[i". inputprice<<ends;cout<< "Revenue:" <<people[i].income<<ends;cout<< "Expenditure:" <<people[i ].charge<<ends<<enDl;return 1;} void Bankstore::D ig () {int i,n,m;cout<< "Please enter the number of subsequent customers:"; Cin>>n;cout<<endl;for (i=0;i<n;i++) { cout<< "This is the section" << (i+1) << "Customer Information" <<endl;people[amount+i].banknumber=amount+i+1;cout<< " Customer's name: ";cin>>people[amount+i].name;cout<<" lump sum deposit: "Cin>>people[amount+i].inputprice;cout << "Revenue:";cin>>people[amount+i].income;cout<< "Expenditure:";cin>>people[amount+i].charge;cout< <endl;} cout<< "The information of these customers is as follows" <<endl;for (i=0;i<amount+n;i++) {cout<< "Customer Information:" <<people[i]. banknumber<<ends;cout<< "Customer's name:" <<people[i].name<<ends;cout<< "lump sum deposit:" << people[i].inputprice<<ends;cout<< "Revenue:" <<people[i].income<<ends;cout<< "Expenses:" < <people[i].charge<<ends<<endl;} Amount=amount+n;ofstream os ("People.txt", ios_base::out|ios_base::binary); Create, open file for (m=0;m<amount;m++) {Os.write (reinterpret_cast<char*> (& (People[m))), sizeof (Bankstore)); Export file}os.close (); Close file}void bankstore::changemessage ()//Transact (trade start) Information {int n,i,m;cout<< "the first few customers want to transact business (enter a customer account):";cin>>n; cout<<endl;cout<< "Please enter modified information" <<endl;cout<< "Customer Name:";cin>>people[n-1].name;cout< < "real-time deposit margin:";cin>>people[n-1].inputprice;cout<< "How much money is paid:";cin>>people[n-1].income;cout< < "How much is spent:";cin>>people[n-1].charge;cout<<endl;cout<< "Customer information after business:" <<endl;people[n-1 " . Tradeamount++;for (i=0;i<amount;i++) {cout<< "Customer Info:" <<people[i].banknumber<<ends;cout< < "customer's name:" <<people[i].name<<ends;cout<< "lump sum deposit:" <<people[i].inputprice<<ends ;cout<< "Revenue:" <<people[i].income<<ends;cout<< "Expenditure:" <<people[i].charge<<ends <<endl;} Ofstream os ("People.txt", ios_base::out|ios_base::binary); Create, open file for (m=0;m<amount;m++) {Os.write (reinterpret_cast<char*> (& (People[m])), sizeof (Bankstore)); Export File}os.closE (); Close the file}void bankstore::search_banknumber ()//by account {int n;cout<< "Please enter the customer account number: (Query by the second count, one at a time)";cin>>n;cout< <endl;if (n<=amount) {cout<< "Customer Information:" <<people[i].banknumber<<ends;cout<< "Customer's name:" <<people[i].name<<ends;cout<< "Lump sum deposit:" <<people[i].inputprice<<ends;cout< < revenue: <<people[i].income<<ends;cout<< expenses: <<people[i].charge<<ends<< Endl;} cout<< "Query end or input error, please select:" <<endl;cout<< "1, re-query (can change the way OH). 2. Go back to the main menu. "<<endl;} void Bankstore::search_name ()//by customer name {int I;char x[20];cout<< "Please enter the customer's name: (Query by the second count, one at a time)";cin>>x;cout< <endl;for (i=0;i<amount;i++) {if (strcmp (people[i].name,x) ==0)//strcmp is used to compare strings. Tname and x{cout<< "Customer Information:" <<people[i].banknumber<<ends;cout<< "Customer's name:" <<people[i].name<<ends;cout<< " Lump sum deposit: "<<people[i].inputprice<<ends;cout<<" Revenue: "<<people[i].income<<ends;cout << "Expenditure:" <≪people[i].charge<<ends<<endl;}} cout<< "Query end or input error, please select:" <<endl;cout<< "1, re-query (can change the way OH). 2. Go back to the main menu. "<<endl;} void Bankstore::show ()//display Information {int i;for (i=0;i<amount;i++) {cout<< "Customer Information:" <<people[i].banknumber< <ends;cout<< "Customer's name:" <<people[i].name<<ends;cout<< "lump sum deposit:" <<people[i ". inputprice<<ends;cout<< "Revenue:" <<people[i].income<<ends;cout<< "Expenditure:" <<people[i ].charge<<ends<<endl;}} void Bankstore::D eleteaccount () {char y[20];int n,m;cout<< "The name of the customer who came to the door:"; cin>>y;for (int i=0;i<amount; i++) {if (strcmp (people[i].name,y) ==0)//strcmp is used to compare strings. Tname and Y{for (; i<amount;i++) {people[i]=people[i+1];p eople [I].num=i+1;} amount=amount-1; }}cout<< "The total information of the customer after deletion is:" <<endl;for (m=0;m<amount;m++) {cout<< "Customer Information:" <<people[i]. banknumber<<ends;cout<< "Customer's name:" <<people[i].name<<ends;cout<< "lump sum deposit:" << people[i].inputprice<<ends;cout<< "Revenue:" <<people[i].income<<ends;cout<< "Expenditure:" <<people[i].charge<<ends <<endl;} Ofstream os ("People.txt", ios_base::out|ios_base::binary); Create, open file for (n=0;n<amount;n++) {Os.write (reinterpret_cast<char*> (& (People[n])), sizeof (Bankstore)); Export file}os.close (); Close file}void Clear ()//clear screen function {char a;a=getchar (); System ("CLS");} void Menuprint ()//Main Menu {cout<< "\t***** Tin's Bank * * * * * * * *" <<endl;cout<< "\t* 1. Account Opening * "<<endl;cout<<" \t* 2. Query Customer Information * "<<endl;cout<<" \t* 3. Show Customer Information * "<<endl;cout< < "\t* 4. Show Trading Frequency *" <<endl;cout<< "\t* 5. \t* * "<<endl;cout<<" 6. Exit the system * "<<endl;cout<<" \t*7. Swipe the screen once and do not exit * "<<endl;cout<<" \t********************** "<< endl;cout<< "Please enter the action you want to take (1~7):" <<endl;} int main ()//main function {Bankstore tin; Defines the object int n;do{menuprint (); Call main Menu Cin>>n;cout<<endl;switch (n) {Case 1://Account opening {int a;cout<< "Input Mode" <<endl;cout<< "1. Account Opening" <<endl;cout<< "2. Import customer Information" <<endl;cout<< "3." <<endl;cout<< "4. Trade (Modify)" <<endl;cout<< "5. Back to main Menu" <<endl;cin>>a;cout< <endl;switch (a) {Case 1://Call to create function people. Input (); Break;case 2://Call file read-in function people. Input_2 (); Break;case 3:people. Dig (); break;case 4:people.changemessage () break;case 5:break;default:cout<< "Your input is wrong, please re-select" <<endl; break;} break;} Case 2://query {int a;cout<< "Query method" <<endl;cout<< "1. By Account" <<endl;cout<< "2. Query by Customer name" < <endl;cout<< "3. Return to Main Menu" <<endl;cin>>a;cout<<endl;switch (a) {case 1:people. Search_banknumber (); int F;cin>>f;switch (f) {case 1:people. Search_name (); Break;case 2:cout<< "Please make sure to inquire again, thank you!" "<<endl;cout<<endl;break;} Break;case 2://Call function (check by goods name) people. Search_name (); int O;cin>>o;switch (o) {case 1:people. Search_name (); Break;case 2:cout<< "Please make sure to inquire again, thank you!" "<<endl;cout<<endl;break;} Break;case 3:break;default:cout<< "Your input is wrong, please re-select" <<endl;break;} break;} Case 3://Display people. Show (); Break;case 4:cout<< "to see which client's trading frequency: (enter customer account)" <<endl;cin>>k;cout<<people[k ". tradeamount<< "Times" <<endl;break;case 5://delete Information people. DeleteAccount (); Break;case 6://Exit exit (0); break;case 7:clear ();break;default:cout<< "Your input is wrong, please re-select" << Ends;break;}} while (1); return 0;}
It seems to be a big fix, this program is not to be finished. Haha, I try.
C + + data structure Course Design Report (No. 1th) "Internet of Things 1132-11"