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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
|
#include <iostream>
#include <string.h>
#include <ctype.h>
#include <fstream>
#include <iomanip>
using namespace std;
//structs provided from the assignment description
struct Edu{
char univ[128]; // a c-string to store the university name
char major[64]; // a c-string to store the major
int graduate_year; // graduation year
float GPA; // GPA
};
struct Basics{
char fname[64]; // a c-string to store the first name
char lname[64]; // a c-string to store the last name
char email[64]; // a c-string to store the email address
Edu edu; // an Edu object to store the ed. background
};
struct Exp{
char company[64]; // a c-string to store the company name
char start_date[64]; // a c-string to store the start date
char end_date[64]; // a c-string to store the end date
char des[1024]; // the description of the work experience
};
/*******************************************************************
** Function:
** Description:
** Parameters:
** Pre-conditions:
** Post-conditions:
*******************************************************************/
void get_skills(string sk[], int sk_size, int *sCount){
int skillCount = 0;
string temp = "";
cout << "\nEnter your skills one-by-one : (Enter a '.' to stop entering skills) " << endl;
while (temp[0] != '.'){
getline(cin, temp);
sk[skillCount] = temp;
skillCount++;
}
*sCount = skillCount - 1;
}
/*******************************************************************
** Function:
** Description:
** Parameters:
** Pre-conditions:
** Post-conditions:
*******************************************************************/
bool validateDate(string temp){
if (isdigit(temp[0]) && (isdigit(temp[1])) && (temp[2] == '-') && (isdigit(temp[3])) && (isdigit(temp[4])) && (temp[5] == '-') && (isdigit(temp[6])) && (isdigit(temp[7])))
return true;
return false;
}
/*******************************************************************
** Function:
** Description:
** Parameters:
** Pre-conditions:
** Post-conditions:
*******************************************************************/
bool validateEmail(string temp){
bool check_a = false;
bool check_dot = false;
for (char i : temp){
if (i == '@')
check_a = true;
if (i == '.')
check_dot = true;
}
return check_a && check_dot;
}
/*******************************************************************
** Function:
** Description:
** Parameters:
** Pre-conditions:
** Post-conditions:
*******************************************************************/
void get_basics_and_edu(Basics *bc, Edu *ed){
string temp;
cout << "\nEnter your first name : ";
getline(cin, temp);
strcpy(bc->fname, temp.c_str());
cout << "Enter your last name : ";
getline(cin, temp);
strcpy(bc->lname, temp.c_str());
while (true){
cout << "Enter your E-mail address : ";
getline(cin, temp);
if (validateEmail(temp)){
strcpy(bc->email, temp.c_str());
break;
}
else{
cout << "E-mail not valid! Try again." << endl;
}
}
cout << "\nEnter your University/College : ";
getline(cin, temp);
strcpy(ed->univ, temp.c_str());
cout << "Enter your Major : ";
getline(cin, temp);
strcpy(ed->major, temp.c_str());
cout << "Enter your Graduation year : ";
cin >> ed->graduate_year;
cout << "Enter your GPA : ";
cin >> ed->GPA;
cin.ignore(1, '\n');
}
/*******************************************************************
** Function:
** Description:
** Parameters:
** Pre-conditions:
** Post-conditions:
*******************************************************************/
void get_one_exp(Exp *ex){
string temp;
cout << "\nEnter your Company/Employer : ";
getline(cin, temp);
strcpy(ex->company, temp.c_str());
while (true){
cout << "Enter start date in dd-mm-yy format : ";
getline(cin, temp);
if (validateDate(temp)){
strcpy(ex->start_date, temp.c_str());
break;
}
else{
cout << "\nDate not valid! Try again." << endl;
}
}
while (true){
cout << "Enter end date in dd-mm-yy format : ";
getline(cin, temp);
if (validateDate(temp)){
strcpy(ex->end_date, temp.c_str());
break;
}
else{
cout << "\nDate not valid! Try again." << endl;
}
}
cout << "Enter description : ";
getline(cin, temp);
if (temp == "")
strcpy(ex->des, "None");
else
strcpy(ex->des, temp.c_str());
}
/*******************************************************************
** Function:
** Description:
** Parameters:
** Pre-conditions:
** Post-conditions:
*******************************************************************/
void get_exp(Exp ex[], int ex_size, int *eCount){
int expCount = 0;
char conf;
cout << "\nWork Experience : " << endl;
while (true){
get_one_exp(&(ex[expCount]));
expCount++;
if (expCount == ex_size)
break;
cout << "\nDo you want to add more experiences? (y / n) : ";
cin >> conf;
cin.ignore(1, '\n');
if (tolower(conf) != 'y')
break;
}
*eCount = expCount;
}
/*******************************************************************
** Function:
** Description:
** Parameters:
** Pre-conditions:
** Post-conditions:
*******************************************************************/
void build_resume(ofstream &f, Basics b, Exp ex[], int ex_size, string sk[], int sk_size, Edu e){
f << string(100, '-') << endl;
f << string(39, ' ') << string(5, '=') << " RESUME " << string(5, '=') << endl;
f << "\n\n\tBasic Information :- " << endl
<< endl;
f << setw(35) << "First Name "
<< ": " << b.fname << endl;
f << setw(35) << "Last Name "
<< ": " << b.lname << endl;
f << setw(35) << "Email Address "
<< ": " << b.email << endl;
f << "\n\n\tEducation Background :- " << endl
<< endl;
f << setw(35) << "University/College "
<< ": " << e.univ << endl;
f << setw(35) << "Major "
<< ": " << e.major << endl;
f << setw(35) << "Graduation year "
<< ": " << e.graduate_year << endl;
f << setw(35) << "GPA "
<< ": " << e.GPA << endl;
f << "\n\n\tWork Experience :- " << endl;
for (int i = 0; i < ex_size; i++){
f << endl;
f << setw(15) << i + 1 << "." << endl;
f << setw(35) << "Company/Employer "
<< ": " << ex[i].company << endl;
f << setw(35) << "Start date "
<< ": " << ex[i].start_date << endl;
f << setw(35) << "End date "
<< ": " << ex[i].end_date << endl;
f << setw(35) << "Description "
<< ": " << ex[i].des << endl;
}
f << "\n\n\tSkills :- " << endl;
for (int i = 0; i < sk_size; i++){
f << endl;
f << setw(15) << i + 1 << ". ";
f << sk[i] << endl;
}
}
int main(){
struct Exp *ex = new Exp[5];
struct Basics bc;
struct Edu ed;
string *skills = new string[10];
int skillCount = 0;
int expCount = 0;
get_basics_and_edu(&bc, &ed);
get_exp(ex, 5, &expCount);
get_skills(skills, 10, &skillCount);
string ext = ".txt";
string filename = bc.lname + ext;
ofstream f;
f.open(filename);
build_resume(f, bc, ex, expCount, skills, skillCount, ed);
f.close();
delete[] ex;
delete[] skills;
}
|