Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.7 kB
2
Indexable
Never
#include<iostream>
#include<string>
using namespace std;

struct CompanyPeople
{
	string FirstName;
	string LastName;
	int Age;
	string Gender;
	char Personal_ID[9];
	int Unique_Employee_Number;
};
int main() {
	
	CompanyPeople TuanLQ10;
	cout << "Nhap First Name: "; 
	cin >> TuanLQ10.FirstName;
	cout << endl;

	cout << "Nhap Last Name: ";
	cin >> TuanLQ10.LastName; 
	cout << endl;
	
	do {
		cout << "Nhap Age(0->100): ";
		cin >> TuanLQ10.Age;
		cout << endl;
	} while (TuanLQ10.Age < 0 || TuanLQ10.Age>100);
	
	do {
		cin.get();
		cout << "Nhap Gender(Male or Female): ";
		getline(cin,TuanLQ10.Gender);
		cout << endl;
	} while ((TuanLQ10.Gender).compare("Male") != 0 && (TuanLQ10.Gender).compare("Female")!=0);

	int a = 0;
	do {
	
		cout << "Nhap Personal ID(9 chu so): ";
			cin.getline(TuanLQ10.Personal_ID,9);
			
			for (int i = 0; i < 9; i++) {
				if (static_cast<int>(TuanLQ10.Personal_ID[i]) > 47 && static_cast<int>(TuanLQ10.Personal_ID[i]) < 58) {
					a = 1; }
				else { a = 0; }
			}
		cout << endl;
	} while (a == 0);

	do {
		cout << "Nhap Unique Employee Number(0->99999999): ";
		cin >> TuanLQ10.Unique_Employee_Number;
		cout << endl;
	} while (TuanLQ10.Unique_Employee_Number < 0 || TuanLQ10.Unique_Employee_Number > 99999999);

	    cout << "First Name: " << TuanLQ10.FirstName << endl;
	    cout << "Last Name: " << TuanLQ10.LastName << endl;
	    cout << "Age: " << TuanLQ10.Age << endl;
		cout << "Gender: " << TuanLQ10.Gender << endl;
		cout << "Personal ID: " << TuanLQ10.Personal_ID << endl;
		cout << "Unique Employee Number: " << TuanLQ10.Unique_Employee_Number << endl;
		cout << static_cast<int>('5') << '\n';
	return 0;

}