wheelsmanx

CPS 171 Machine Problem 6

Nov 1st, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. // ConsoleApplication1.cpp : Defines the entry point for the console application.
  2.  
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <string>
  7. #include <fstream>
  8. #include <wctype.h>
  9.  
  10. using namespace std;
  11.  
  12. string newstring;
  13. string currentstring;
  14.  
  15. string firstname;
  16. string middlename;
  17. string lastname;
  18. string fullname;
  19.  
  20. void test() {
  21. cout << endl << "This is a test" << endl;
  22. }
  23.  
  24. void isstatus(char digit, char digit2) {
  25. enum begin { single = 'S', married = 'M', divorced = 'D' };
  26.  
  27. if (digit2 == 'M') {
  28. currentstring = "Mr.";
  29.  
  30. }else
  31. if(digit2 == 'F')
  32. switch (digit) {
  33. case single:
  34. currentstring = "Ms.";
  35. break;
  36. case married:
  37. currentstring = "Mrs.";
  38. break;
  39. case divorced:
  40. currentstring = "Ms.";
  41. break;
  42. default:
  43. cout << "Failed to Identify The IsStatus";
  44. cout << endl << digit << endl;
  45. break;
  46.  
  47. }
  48.  
  49. }
  50.  
  51.  
  52. void nameparser(string things, float position) {
  53. int i = position;
  54. int a;
  55. int b;
  56. string tempstring2;
  57.  
  58.  
  59. while (things[i] != '\0') {
  60. if (things[i] != ' ') {
  61. tempstring2 += things[i];
  62. }
  63. if (things[i] == ',') {
  64. lastname = tempstring2;
  65. b = lastname.length();
  66. lastname[b - 1] = ' ';
  67. tempstring2 = ' ';
  68. }
  69. if (things[i + 1] == '\0' || things[i - 1] == '.') {
  70. if (tempstring2 != " ") {
  71. firstname = tempstring2;
  72. }
  73. a = firstname.length();
  74. if (firstname[a - 1] == '.') {
  75. middlename = firstname[a - 2];
  76. middlename += firstname[a];
  77.  
  78. firstname.erase(a - 2, a);
  79.  
  80. }
  81. tempstring2 = ' ';
  82. }
  83. i++;
  84. }
  85. }
  86.  
  87.  
  88.  
  89. int main()
  90. {
  91. ifstream fileInput;
  92. fileInput.open("C:\\temp\\New Text Document.txt");
  93. while (!fileInput.eof())
  94. {
  95.  
  96. getline(fileInput, newstring);
  97. isstatus(newstring[2],newstring[0]);
  98. nameparser(newstring, 4);
  99. newstring.erase(0, 4);
  100. cout << "Original String: " << newstring << endl << "Standard String: ";
  101. cout << currentstring << " " << firstname << " " << middlename << " " << lastname << " " << endl << endl;
  102. }
  103.  
  104.  
  105.  
  106. system("pause");
  107. return 0;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment