1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
int main()
{
//welcomeMSG();// Welcome message and what the program does
//declare the necessary constants
//create the Users and Contacts array of size 1000
const int CAPACITY = 1000;
int size = 0;
float user_ids[CAPACITY];
float contact_with[CAPACITY];
float contact_start[CAPACITY];
float contact_end[CAPACITY];
float distance[CAPACITY];
float duration[CAPACITY];
const int cap = 1000;
int size2 = 0;
float users_ids[cap];
string fname[cap];
string lname[cap];
char gender[cap];
int age[cap];
int phone[cap];
string address[cap];
//read the files using the functions
//function to read the contacts.txt file
ifstream infile1; //Contact.txt
infile1.open("contacts.txt");
if (infile1.is_open())
{
string temp;
float id, cw, cs, ce, dist; //place holders
getline(infile1, temp);
while (infile1 >> id >> cw >> cs >> ce >> dist)
{
user_ids[size]= id;
contact_with[size]=cw;
contact_start[size]=cs;
contact_end[size]=ce;
distance[size]=dist;
size++;
//DEBUGGER
/*
float dur = ce - cs;
cout<< id << " " <<cw<< " " <<dur<< " " <<dist<<endl;
*/
}
}
else
{
cout << "Could not open" << endl;
}
//function to read the users.txt file
ifstream infile2; //User.txt
infile2.open("users.txt");
if (infile2.is_open())
{
string temp2;
float u_id,u_age,u_phone;
string Fn, Ln, add;
char Gend;
getline(infile2, temp2);
while (infile2 >> u_id >> Fn >> Ln >> Gend >> u_age>>u_phone>>add) // Get the data from user text
{
users_ids[size2] = u_id;
fname[size2] = Fn;
lname[size2] = Ln;
gender[size2] = Gend;
age[size2] = u_age;
phone[size2] = u_phone;
address[size2] = add;
size2++;
}
}
else
{
cout << "Could not open" << endl;
}
cout<< "\n\nselect your choice: \n";
cout<< "\n\n1. Exit program \n";
cout<< "\n\n2. Print users \n";
cout<< "\n\n3. Print all the contacts \n";
cout<< "\n\n4. Print all the contacts who came into contact \n";
cout<< "\n\n5. Search by user ID \n";
cout<< "\n"<<endl;
cout<< "\n\n Enter your option"<<endl;
int op;
cin >> op;
if (op == 1 )
return 0;
// print funcs
if (op == 2 )
{
PrintUsers( users_ids, fname, lname, gender, age, phone, address, size2);//print users
}
if (op == 3 )
{
PrintContacts(user_ids,contact_with,contact_start,contact_end,distance, size);//print contacts
}
if (op == 4 )
{
CameIntoCon(user_ids,contact_with,contact_start,contact_end,distance, size);//print Con who came into contact
}
//user_ids,contact_with,contact_start,contact_end,distance tags
//rest of the program…
system("PAUSE");
return 0;
}
|