Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <istream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. struct inquiry {
  10. string number;
  11. string name;
  12. int age;
  13. string date;
  14. int phone;
  15. string address;
  16. string targetIntake;
  17. string followup1;
  18. string followup2;
  19. string feedback;
  20. };
  21.  
  22. inquiry inqArr[20];
  23. int nextLoc = 0;
  24.  
  25. //mainmenu
  26. void mainMenu();
  27.  
  28. //view inquiry
  29. void viewAll();
  30. void searchName(string searchKey);
  31. void searchNo(string searchKey);
  32.  
  33. //inquiry modifications
  34. void addNewInquiry(int n);
  35. void editInq(string searchKey);
  36. void deleteInq(string searchKey);
  37.  
  38. //followups
  39. void updateFollowup1(string searchKey);
  40. void updateFollowup2(string searchKey);
  41. void updateFollowup3(string searchKey);
  42. void updateFinalfb(string searchKey);
  43.  
  44.  
  45. //User verification
  46.  
  47. int main() {
  48. string uname, passwd;
  49. cout << "Enter your username: ";
  50. cin >> uname;
  51. cout << "Enter your password: ";
  52. cin >> passwd;
  53. if (uname == "1" & passwd == "1") {
  54. mainMenu();
  55. }
  56. else {
  57. cout << "Invalid Username or Password" << endl;
  58. }
  59. system("pause");
  60. }
  61.  
  62. //Main Menu
  63. void mainMenu() {
  64. string ans = "x";
  65. do {
  66. system("cls");
  67. int opt;
  68. string searchKey;
  69. cout << "==================Main Menu======================" << endl;
  70. cout << "1. View Previous Inquiries " << endl;
  71. cout << "2. Add New Inquiry" << endl;
  72. cout << "3. Edit/Delete an Inquiry" << endl;
  73. cout << "4. Update FOLLOW-UPs" << endl;
  74. cout << "5. Update Final Feedback" << endl;
  75. cout << "6. Logout" << endl;
  76. cout << "Enter Your Option: ";
  77. cin >> opt;
  78. switch (opt) {
  79. case 1:
  80. do {
  81. system("cls");
  82. int opt;
  83. cout << "1. View All Inquiries" << endl;
  84. cout << "2. Search By Number" << endl;
  85. cout << "3. Search By Name" << endl;
  86. cout << "9. Back to Mainmenu" << endl;
  87. cout << "Enter Your Option: ";
  88. cin >> opt;
  89. switch (opt)
  90. {
  91. case 1:
  92. viewAll();
  93. break;
  94. case 2:
  95. cout << "Enter the Inquiry Number : " << endl;
  96. cin >> searchKey;
  97. searchNo(searchKey);
  98. break;
  99. case 3:
  100. cout << "Enter the Inquirer name : " << endl;
  101. cin >> searchKey;
  102. searchName(searchKey);
  103. break;
  104. case 9:
  105. mainMenu();
  106. default:
  107. cout << "Invalid Option" << endl;
  108. break;
  109. }
  110. cout << "Do you want to continue [Y/N]: ";
  111. cin >> ans;
  112. } while (ans == "y" | ans == "Y");
  113. break;
  114.  
  115. case 2:
  116. system("cls");
  117. int n;
  118. cout << "How many inquaries do you want to add : ";
  119. cin >> n;
  120. addNewInquiry(n);
  121. break;
  122. case 3:
  123. do {
  124. system("cls");
  125. int opt;
  126. cout << "1. Edit an Inquiry" << endl;
  127. cout << "2. Delete an Inquiry" << endl;
  128. cout << "3. Delete all Inquiries" << endl;
  129. cout << "9. Back to Mainmenu" << endl;
  130. cout << "Enter Your Option: ";
  131. cin >> opt;
  132. switch (opt)
  133. {
  134. case 1:
  135. cout << "Enter the Inquiry Number : " << endl;
  136. cin >> searchKey;
  137. editInq(searchKey);
  138. break;
  139. case 2:
  140. cout << "Enter the Inquiry Number : " << endl;
  141. cin >> searchKey;
  142. deleteInq(searchKey);
  143. break;
  144. case 9:
  145. mainMenu();
  146. default:
  147. cout << "Invalid Option" << endl;
  148. break;
  149. }
  150. cout << "Do you want to continue [Y/N]: ";
  151. cin >> ans;
  152. } while (ans == "y" | ans == "Y");
  153. break;
  154. case 4:
  155.  
  156. do {
  157. system("cls");
  158. int opt;
  159. cout << "1. Update First Followup" << endl;
  160. cout << "2. Update second Followup" << endl;
  161. cout << "3. update followups and feedback" << endl;
  162. cout << "9. Back to Mainmenu" << endl;
  163. cout << "Enter Your Option: ";
  164. cin >> opt;
  165. switch (opt)
  166. {
  167. case 1:
  168. cout << "Enter the Inquiry Number : " << endl;
  169. cin >> searchKey;
  170. updateFollowup1(searchKey);
  171. break;
  172. case 2:
  173. cout << "Enter the Inquiry Number : " << endl;
  174. cin >> searchKey;
  175. updateFollowup2(searchKey);
  176. break;
  177. case 3:
  178. cout << "Enter the Inquiry Number : " << endl;
  179. cin >> searchKey;
  180. updateFollowup3(searchKey);
  181. break;
  182. case 9:
  183. mainMenu();
  184. default:
  185. cout << "Invalid Option" << endl;
  186. break;
  187. }
  188. cout << "Do you want to continue [Y/N]: ";
  189. cin >> ans;
  190. } while (ans == "y" | ans == "Y");
  191. break;
  192.  
  193. break;
  194. case 5:
  195. cout << "Enter the Inquiry Number : " << endl;
  196. cin >> searchKey;
  197. updateFinalfb(searchKey);
  198. break;
  199. case 6:
  200. main();
  201. break;
  202. default:
  203. cout << "Invalid Option" << endl;
  204. break;
  205. }
  206. cout << "Do you want to continue [Y/N]: ";
  207. cin >> ans;
  208. } while (ans == "y" | ans == "Y");
  209. }
  210.  
  211. //main menu end
  212.  
  213. //view all inquiry
  214. void viewAll() {
  215. system("cls");
  216. for (int i = 0; i<nextLoc; i++) {
  217. cout << "============================================" << endl;
  218. cout << "Inquiry Number : " << inqArr[i].number << endl;
  219. cout << "Inquirer Name : " << inqArr[i].name << endl;
  220. cout << "Date of Inquiry : " << inqArr[i].date << endl;
  221. cout << "Age : " << inqArr[i].age << endl;
  222. cout << "Phone Number : " << inqArr[i].phone << endl;
  223. cout << "Address : " << inqArr[i].address << endl;
  224. cout << "Targeted Intake : " << inqArr[i].targetIntake << endl;
  225. cout << "Follow-Up 1 : " << inqArr[i].followup1 << endl;
  226. cout << "Follow-Up 2 : " << inqArr[i].followup2 << endl;
  227. cout << "FeedBack : " << inqArr[i].feedback << endl;
  228. cout << "============================================" << endl;
  229. }
  230. }
  231.  
  232. //search by inquiry number
  233. void searchNo(string searchKey) {
  234. bool flag = false;
  235. int i;
  236. for (i = 0; i<nextLoc; i++) {
  237. if (inqArr[i].number == searchKey) {
  238. flag = true;
  239. break;
  240. }
  241. }
  242. if (flag) {
  243. cout << "============================================" << endl;
  244. cout << "Inquirer Name : " << inqArr[i].name << endl;
  245. cout << "Inquiry Number : " << inqArr[i].number << endl;
  246. cout << "Date of Inquiry : " << inqArr[i].date << endl;
  247. cout << "Age : " << inqArr[i].age << endl;
  248. cout << "Phone Number : " << inqArr[i].phone << endl;
  249. cout << "Address : " << inqArr[i].address << endl;
  250. cout << "Targeted Intake : " << inqArr[i].targetIntake << endl;
  251. cout << "Follow-Up 1 : " << inqArr[i].followup1 << endl;
  252. cout << "Follow-Up 2 : " << inqArr[i].followup2 << endl;
  253. cout << "FeedBack : " << inqArr[i].feedback << endl;
  254. cout << "============================================" << endl;
  255. }
  256. }
  257.  
  258. //add new inq
  259.  
  260. void addNewInquiry(int n) {
  261. for (int i = nextLoc; i<(nextLoc + n); i++) {
  262. cout << "============================================" << endl;
  263. inquiry inqObj;
  264. cout << "Inquiry Number : ";
  265. cin >> inqObj.number;
  266. cout << "Inquirer Name : ";
  267. cin.ignore();
  268. getline(cin, inqObj.name);
  269. cout << "Date of Inquiry : ";
  270. cin >> inqObj.date;
  271. cout << "Age : ";
  272. cin >> inqObj.age;
  273. cout << "Phone Number : ";
  274. cin >> inqObj.phone;
  275. cout << "Address : ";
  276. cin.ignore();
  277. getline(cin, inqObj.address);
  278. cout << "Targeted Intake : ";
  279. cin >> inqObj.targetIntake;
  280. inqArr[i] = inqObj;
  281. cout << "============================================" << endl;
  282. }
  283. nextLoc = nextLoc + n;
  284. }
  285.  
  286. //edit an Inquiry
  287. void editInq(string searchKey) {
  288. bool flag = false;
  289. int i;
  290. for (i = 0; i<nextLoc; i++) {
  291. if (inqArr[i].number == searchKey) {
  292. flag = true;
  293. break;
  294. }
  295. }
  296. if (flag) {
  297. cout << "============================================" << endl;
  298. inquiry inqObj;
  299. inqObj.number = inqArr[i].number;
  300. cout << "Inquirer Name : ";
  301. cin.ignore();
  302. getline(cin, inqObj.name);
  303. cout << "Age : ";
  304. cin >> inqObj.age;
  305. cout << "Phone Number : ";
  306. cin >> inqObj.phone;
  307. cout << "Address : ";
  308. cin.ignore();
  309. getline(cin, inqObj.address);
  310. cout << "Targeted Intake : ";
  311. cin >> inqObj.targetIntake;
  312. inqArr[i] = inqObj;
  313. cout << "============================================" << endl;
  314. }
  315. }
  316.  
  317. //search by name
  318. void searchName(string searchKey) {
  319. bool flag = false;
  320. int i;
  321. for (i = 0; i<nextLoc; i++) {
  322. if (inqArr[i].name == searchKey) {
  323. flag = true;
  324. break;
  325. }
  326. }
  327. if (flag) {
  328. cout << "============================================" << endl;
  329. cout << "Inquirer Name : " << inqArr[i].name << endl;
  330. cout << "Inquiry Number : " << inqArr[i].number << endl;
  331. cout << "Date of Inquiry : " << inqArr[i].date << endl;
  332. cout << "Age : " << inqArr[i].age << endl;
  333. cout << "Phone Number : " << inqArr[i].phone << endl;
  334. cout << "Address : " << inqArr[i].address << endl;
  335. cout << "Targeted Intake : " << inqArr[i].targetIntake << endl;
  336. cout << "Follow-Up 1 : " << inqArr[i].followup1 << endl;
  337. cout << "Follow-Up 2 : " << inqArr[i].followup2 << endl;
  338. cout << "FeedBack : " << inqArr[i].feedback << endl;
  339. cout << "============================================" << endl;
  340. }
  341. }
  342.  
  343.  
  344. //delete an inquiry
  345.  
  346. void deleteInq(string searchKey) {
  347. bool flag = false;
  348. int i;
  349. for (i = 0; i<nextLoc; i++) {
  350. if (inqArr[i].number == searchKey) {
  351. flag = true;
  352. break;
  353. }
  354. }
  355. if (flag) {
  356. cout << "================= Deleting.... ===================" << endl;
  357. int shift = i;
  358. for (; shift<nextLoc; shift++) {
  359. inqArr[shift] = inqArr[shift + 1];
  360. }
  361. nextLoc--;
  362. cout << "================= Deleted! ======================" << endl;
  363. }
  364. }
  365.  
  366.  
  367.  
  368. // update followups
  369. void updateFollowup1(string searchKey) {
  370. bool flag = false;
  371. int i;
  372. for (i = 0; i<nextLoc; i++) {
  373. if (inqArr[i].number == searchKey) {
  374. flag = true;
  375. break;
  376. }
  377. }
  378. if (flag) {
  379. cout << "============================================" << endl;
  380. inquiry inqObj;
  381. inqObj.number = inqArr[i].number;
  382. cout << "Enter Follow-up 1 : ";
  383. cin.ignore();
  384. getline(cin, inqObj.followup1);
  385. inqArr[i] = inqObj;
  386. cout << "============================================" << endl;
  387. }
  388. }
  389.  
  390.  
  391. void updateFollowup2(string searchKey) {
  392. bool flag = false;
  393. int i;
  394. for (i = 0; i<nextLoc; i++) {
  395. if (inqArr[i].number == searchKey) {
  396. flag = true;
  397. break;
  398. }
  399. }
  400. if (flag) {
  401. cout << "============================================" << endl;
  402. cout << "Inquiry Number : " << inqArr[i].number << endl;
  403. cout << "Inquirer Name : " << inqArr[i].name << endl;
  404. inquiry inqObj;
  405. inqObj.number = inqArr[i].number;
  406. cout << "Enter Follow-up 2 : ";
  407. cin.ignore();
  408. getline(cin, inqObj.followup2);
  409. cout << "============================================" << endl;
  410. }
  411. }
  412.  
  413. void updateFollowup3(string searchKey) {
  414. bool flag = false;
  415. int i;
  416. for (i = 0; i<nextLoc; i++) {
  417. if (inqArr[i].number == searchKey) {
  418. flag = true;
  419. break;
  420. }
  421. }
  422. if (flag) {
  423. cout << "============================================" << endl;
  424. inquiry inqObj;
  425. inqObj.number = inqArr[i].number;
  426. cout << "Enter Follow-up 1 : ";
  427. cin.ignore();
  428. getline(cin, inqObj.followup1);
  429. cout << "Enter Follow-up 2 : ";
  430. cin.ignore();
  431. getline(cin, inqObj.followup2);
  432. cout << "Final Feedback : ";
  433. cin.ignore();
  434. getline(cin, inqObj.feedback);
  435. inqArr[i] = inqObj;
  436. cout << "============================================" << endl;
  437. }
  438. }
  439.  
  440. void updateFinalfb(string searchKey) {
  441. bool flag = false;
  442. int i;
  443. for (i = 0; i<nextLoc; i++) {
  444. if (inqArr[i].number == searchKey) {
  445. flag = true;
  446. break;
  447. }
  448. }
  449. if (flag) {
  450. cout << "============================================" << endl;
  451. inquiry inqObj;
  452. inqObj.number = inqArr[i].number;
  453. cout << "Final Feedback : ";
  454. cin.ignore();
  455. getline(cin, inqObj.feedback);
  456. inqArr[i] = inqObj;
  457. cout << "============================================" << endl;
  458. }
  459. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement