Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hi every body please solve my question in my code i should save at least 2 person but i can't please help me .my code is about data bank(save information and print them)
- #include<fstream>
- #include <iostream>
- using namespace std;
- struct Person
- { char password;
- char username[20];
- char first_name[20];
- char last_name[20];
- char father_name[20];
- char birthdate[20];
- char birthplace[20];
- int age;
- char sex[10];
- char nationality[20];
- char job[20];
- char marital_status[20];
- long double phone_number;
- char address[80];
- char blood_type[5];
- float height;
- float weight;
- char allergen_type[20];
- char previous_disease[20];
- long double bank_account;
- char bank_account_expiration_date[20];
- float account_balance;
- };
- int main(){
- while(true){
- cout<<"which person are you? "<<" person[i]<<i"<<" for example ( person=3 << enter 3 )"<<endl;
- int i; cin>>i;if(i==0)break;
- cout<<"which one do you want? "<<" 1.sing up"<<" 2.sing in"<<" 0.exit"<<endl;
- int a; cin>>a;
- if (a == 1)
- {Person p_i;ofstream pepole("information.txt");
- cout<<"please enter your information carefully! "<<endl;
- cout<<"a) Identity information: "<<endl<<endl;
- pepole<<"person ("<<i<<")"<<endl;
- cout<<"password: ";
- cin>>p_i.password;pepole<<"password: "<<p_i.password<<endl;
- cin.ignore();
- cout<<"username: ";
- cin.getline(p_i.username,20);pepole<<"username: "<<p_i.username<<endl;
- cout<<"first name: ";
- cin.getline(p_i.first_name,20);pepole<<"first name: "<<p_i.first_name<<endl;
- cout<<"last name: ";
- cin.getline(p_i.last_name,20);pepole<<"last name: "<<p_i.last_name<<endl;
- cout<<"father name: ";
- cin.getline(p_i.father_name,20);pepole<<"father name: "<<p_i.father_name<<endl;
- cout<<"birthdate: ";
- cin.getline(p_i.birthdate,20);pepole<<"birthdate: "<<p_i.birthdate<<endl;
- cout<<"birthplace: ";
- cin.getline(p_i.birthplace,20);pepole<<"birthplace: "<<p_i.birthplace<<endl;
- cout<<"age: ";
- cin>>p_i.age;pepole<<"age: "<<p_i.age<<endl;
- cin.ignore();
- cout<<"sex: ";
- cin.getline(p_i.sex,10);pepole<<"sex: "<<p_i.sex<<endl;
- cout<<"nationality: ";
- cin.getline(p_i.nationality,20);pepole<<"nationality: "<<p_i.nationality<<endl;
- cout<<"job: ";
- cin.getline(p_i.job,20);pepole<<"job: "<<p_i.job<< endl;
- cout<<"marital status:";
- cin.getline(p_i.marital_status,20);pepole<<"marital status:"<<p_i.marital_status<<endl;
- cout<<"phone number: ";
- cin>>p_i.phone_number;pepole<<"phone number: "<<p_i.phone_number<<endl;
- cin.ignore();
- cout<<"address: ";
- cin.getline(p_i.address,80);pepole<<"address: "<<p_i.address<<endl;
- cout<<endl;
- cout<<"b) Health information: "<<endl<<endl;
- cout<<"blood type: ";
- cin.get(p_i.blood_type,5);pepole<<"blood type: "<<p_i.blood_type<<endl;
- cout<<"height(m): ";
- cin>>p_i.height;pepole<<"height(m): "<<p_i.height<<endl;
- cin.ignore();
- cout<<"weight(kg): ";
- cin>>p_i.weight;pepole<<"weight(kg): "<<p_i.weight<<endl;
- cin.ignore();
- cout<<"allergen type: ";
- cin.getline(p_i.allergen_type,20);pepole<<"allergen type: "<<p_i.allergen_type<<endl;
- cout<<"previous disease:";
- cin.getline(p_i.previous_disease,20);pepole<<"previous disease:"<<p_i.previous_disease<<endl;
- cout<<endl;
- cout<<"c) Banking information: "<<endl<<endl;
- cout<<"bank account: ";
- cin>>p_i.bank_account;pepole<<"bank account: "<<p_i.bank_account<<endl;
- cin.ignore();
- cout<<"bank account expiration date: ";
- cin.getline(p_i.bank_account_expiration_date,6);pepole<<"bank account expiration date: "<<p_i.bank_account_expiration_date<<endl;
- cout<<"account balance: ";
- cin>>p_i.account_balance;pepole<<"account balance: "<<p_i.account_balance<<endl;
- cout<<"thank you! Dear"<<p_i.first_name<<endl;
- cout<<"Your information sucecessfully saved."<<endl;
- cout<<endl;
- }
- else if (a == 2)
- {cout<<"please enter your password: ";
- int c;cin>>c;Person p_i;
- cout<<endl;
- if(p_i.password==c)
- {cout<< "which one your informations do you want? "<<endl;
- cout<< "1)username 2)password 3)first name 4)last name" <<endl;
- cout<< "5)father name 6)birthdate 7)birthplace 8)age" <<endl;
- cout<< "9)sex 10)nationality 11)job 12)martial status"<<endl;
- cout<< "13)phone number 14)address 15)blood type 16)height" <<endl;
- cout<< "17)weight 18)allergen type 19)previous disease 20)bank account" <<endl;
- cout<< "21)bank account expiration date 22)account balance" <<endl;
- int d;cin>>d;
- switch(d)
- {case 1:cout<<p_i.first_name<<" your password is "<<p_i.password<<endl;break;
- case 2:cout<<p_i.first_name<<" your username is "<<p_i.username[20]<<endl;break;
- case 3:cout<<" your first name is"<<p_i.first_name[20]<<endl;break;
- case 4:cout<<p_i.first_name<<" your last name is "<<p_i.last_name[20]<<endl;break;
- case 5:cout<<p_i.first_name<<" your father_name is "<<p_i.father_name[20]<<endl;break;
- case 6:cout<<p_i.first_name<<" your birthdate is "<<p_i.birthdate[20]<<endl;break;
- case 7:cout<<p_i.first_name<<" your birthplace is "<<p_i.birthplace[20]<<endl;break;
- case 8:cout<<p_i.first_name<<" your age is "<<p_i.age<<endl;break;
- case 9:cout<<p_i.first_name<<" your sex is "<<p_i.sex[10]<<endl;break;
- case 10:cout<<p_i.first_name<<" your nationality is "<<p_i.nationality[20]<<endl;break;
- case 11:cout<<p_i.first_name<<" your job is "<<p_i.job[20]<<endl;break;
- case 12:cout<<p_i.first_name<<" your marital status is "<<p_i.marital_status[20]<<endl;break;
- case 13:cout<<p_i.first_name<<" your phone number is "<<p_i.phone_number<<endl;break;
- case 14:cout<<p_i.first_name<<" your address is "<<p_i.address[80]<<endl;break;
- case 15:cout<<p_i.first_name<<" your blood type is "<<p_i.blood_type[5]<<endl;break;
- case 16:cout<<p_i.first_name<<" your height is "<<p_i.height<<endl;break;
- case 17:cout<<p_i.first_name<<" your weight is "<<p_i.weight<<endl;break;
- case 18:cout<<p_i.first_name<<" your allergen type is "<<p_i.allergen_type[20]<<endl;break;
- case 19:cout<<p_i.first_name<<" your previous disease is "<<p_i.previous_disease[20]<<endl;break;
- case 20:cout<<p_i.first_name<<" your bank account is "<<p_i.bank_account<<endl;break;
- case 21:cout<<p_i.first_name<<" your bank account expiration date is "<<p_i.bank_account_expiration_date[6]<<endl;break;
- case 22:cout<<p_i.first_name<<" your account balance is "<<p_i.account_balance<<endl;break;
- }}
- else
- cout<<"your password is worong!"<<endl<<"please enter your password again. ";cout<<endl;
- }
- else if (a == 0)
- break;
- else
- cout<<"wrong input!!!!!"<< endl;
- }cout<<"good bye! have a nice day!";
- return 0;}
Add Comment
Please, Sign In to add comment