By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Logging response times to input/ storing responses.

P: n/a
This is my first program aside from hello world. It is still in progress. I would really like to know how to get a time stamp for the duration of the presentation of each question and the time taken for a response. I would also like to know the best approach to storing responses individually for later review. I am not asking for help in improving the program beyond these items but all constructive criticism is welcome and appreciated. This is not for a class and is for personal use only. There are 72 questions total and I have included the basic structure as including more would be redundant. This is very new to me so the simpler the explanation the better.
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3.  
  4.  
  5.  
  6. int main()
  7.  
  8. {
  9. using namespace std;
  10. char response[256];
  11. float ei = 0;
  12. float tf = 0;
  13. float ins = 0;
  14. float pj = 0;
  15. int y = 0;
  16. int n = 0;
  17. int i = 0;
  18. int e = 0;
  19. int t = 0;
  20. int f = 0;
  21. int in = 0;
  22. int s = 0;
  23. int p = 0;
  24. int j = 0;
  25. int awnser = 0;
  26. cout <<" This is a personality test commonly called the Jung/Briggs-Meyer\n";
  27. cout <<" personality test.  You will be asked questions in which you are required\n";
  28. cout <<" to answer Yes(y) or No(n) as the question applies to you.  The answer you\n";
  29. cout <<" give is the one that most applies to you, even if you agree with niether\n";
  30.  
  31. cout <<" Would you like to take the personality test? select 1 for yes 2 to exit. ";
  32. cin.getline(response,256);
  33. if (strlen(response) == 0) {
  34.     cout <<"Please make a selection ";
  35.     return 1;
  36. }
  37. while ((atoi(response) < 1) | (atoi(response) > 2)) {
  38.     cout <<response<<" - is an invalid selection.";
  39.     return 1;
  40. }
  41. if (atoi(response) == 1) {
  42.     cout <<" 1. You are alomst never late for your appointments. Y/N ";
  43.     cin.getline(response,256);
  44.     awnser = atoi(response);
  45.     if (awnser == 'y' || 'Y')
  46.         y = j++;
  47.     else
  48.     if (awnser == 'N'|| 'n')
  49.         n = p++;
  50.      cout <<"2. You like being engaged in an active and fast paced job. Y/N ";
  51.      cin.getline(response,256);
  52.     awnser = atoi(response);
  53.     if (awnser == 'y' || 'Y')
  54.         y = e++;
  55.     else
  56.     if (awnser == 'N'|| 'n')
  57.         n = i++;
  58.     cout <<"3. You enjoy having a wide circle of acquaintances. Y/N ";
  59.     cin.getline(response,256);
  60.     awnser = atoi(response);
  61.     if (awnser == 'y' || 'Y')
  62.         y = e++;
  63.     else
  64.     if (awnser == 'N'|| 'n')
  65.         n = i++;
  66.      cout <<"4. You feel involved when watching soaps. Y/N ";
  67.       cin.getline(response,256);
  68.     awnser = atoi(response);
  69.     if (awnser == 'y' || 'Y')
  70.         y = f++;
  71. else
  72.     if (awnser == 'N'|| 'n')
  73.         n = t++;
  74.     cout <<"5. You are usually the first to react to an unexpected event:\n";
  75.         cout <<" the telephone ringing or unexpected question. Y/N ";
  76.     cin.getline(response,256);
  77.     awnser = atoi(response);
  78.     if (awnser == 'y' || 'Y')
  79.         y = e++;
  80.     else
  81.     if (awnser == 'N'|| 'n')
  82.         n = i++;
  83.     cout <<"6. You are more interested in a general idea than in the details\n";
  84.         cout <<" of its realization. Y/N ";
  85.     cin.getline(response,256);
  86.     awnser = atoi(response);
  87.     if (awnser == 'y' || 'Y')
  88.         y = in++;
  89.     else
  90.     if (awnser == 'N'|| 'n')
  91.         n = s++;
  92.     cout <<"7. You tend to be unbiased even if this might endanger your good\n";
  93.         cout <<" relations with people. Y/N ";
  94.     cin.getline(response,256);
  95.     awnser = atoi(response);
  96.     if (awnser == 'y' || 'Y')
  97.         y = t++;
  98. else
  99.     if (awnser == 'N'|| 'n')
  100.         n = f++;  
  101.  
The latter part will compare items e and i and if e<i than that person will score introverted which will be divided to give the percent of introverted responses. I do not need help with this part but am unsure if what I am asking for will not require an over hall of the code thus far or can be incorporated into existing code. I am also in agreement that awnser is not a word, but after coping and pasting 71 questions it has become a variable.
Oct 19 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.