Advertisement
Guest User

Untitled

a guest
May 31st, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7. int question_gen(string question, bool invert);
  8.  
  9. int main()
  10. {
  11.     int extra_score(0),agree_score(0),con_score(0),emo_score(0),open_score(0);
  12.    
  13.     cout << "Welcome to the Big Five Index, originally written by Oliver P. John.\n";
  14.     cout << "Please enter a number between 1 and 5 for each question.\n";
  15.     cout << "1 is disagree strongly, 2 is disagree, 3 is neutral, 4 is agree, 5 is agree strongly.\n";
  16.     cout << "There are 54 questions in this test, so have fun and good luck!\n\n";
  17.     cout << "I see myself as someone who...\n";
  18.  
  19.     extra_score += question_gen("Is talkative: ", false);
  20.     agree_score += question_gen("Tends to find fault with others: ", true);
  21.     con_score += question_gen("Does a thorough job: ", false);
  22.     open_score += question_gen("Has a wide range of interests: ", false);
  23.     emo_score += question_gen("Is depressed, blue: ", true);
  24.     open_score += question_gen("Is original, comes up with new ideas: ", false);
  25.     extra_score += question_gen("Is reserved: ", true);
  26.     agree_score += question_gen("Is helpful and unselfish with others: ", false);
  27.     open_score += question_gen("Prefers the conventional, traditional: ", true);
  28.     con_score += question_gen("Can be somewhat careless: ", true);
  29.     emo_score += question_gen("Is relaxed, handles stress well: ", false);
  30.     open_score += question_gen("Is curious about many different things: ", false);
  31.     extra_score += question_gen("Is full of energy: ", false);
  32.     open_score += question_gen("Prefers work that is routine and simple: ", true);
  33.     agree_score += question_gen("Starts quarrels with others: ", true);
  34.     con_score += question_gen("Is a reliable worker: ", false);
  35.     emo_score += question_gen("Can be tense: ", true);
  36.     open_score += question_gen("Is clever, sharp witted: ", false);
  37.     extra_score += question_gen("Tends to be quiet: ", true);
  38.     open_score += question_gen("Values artistic, aesthetic experiences: ", false);
  39.     con_score += question_gen("Tends to be disorganized: ", true);
  40.     emo_score += question_gen("Is emotionally stable, not easily upset: ", false);
  41.     open_score += question_gen("Has an active imagination: ", false);
  42.     con_score += question_gen("Perseveres until the task is finished: ", false);
  43.     agree_score += question_gen("Is somtimes rude to others: ", true);
  44.     emo_score += question_gen("Has unwavering self-confidence: ", false);
  45.     open_score += question_gen("Is inventive: ", false);
  46.     agree_score += question_gen("Is generally trusting: ", false);
  47.     con_score += question_gen("Tends to be lazy: ", true);
  48.     open_score += question_gen("Is clear-thinking, intelligent: ", false);
  49.     emo_score += question_gen("Worries a lot: ", false);
  50.     open_score += question_gen("Wants things to be simple and clear-cut: ", true);
  51.     extra_score += question_gen("Is sometimes shy, inhibited: ", true);
  52.     agree_score += question_gen("Has a forgiving nature: ", false);
  53.     open_score += question_gen("Is idealistic, can be a dreamer: ", false);
  54.     con_score += question_gen("Does things efficiently: ", false);
  55.     emo_score += question_gen("Can be moody: ", true);
  56.     open_score += question_gen("Is ingenious, a deep thinking: ", false);
  57.     extra_score += question_gen("Generates a lot of enthusiasm: ", false);
  58.     agree_score += question_gen("Can be cold and aloof: ", true);
  59.     open_score += question_gen("Enjoys thinking about complicated problems: ", false);
  60.     con_score += question_gen("Makes plans and follows through with them: ", false);
  61.     emo_score += question_gen("Remains calm in tense situations: ", false);
  62.     open_score += question_gen("Likes to reflect, play with ideas: ", false);
  63.     agree_score += question_gen("Is considerate and kind to almost everyone: ", false);
  64.     extra_score += question_gen("Seeks adventure and excitement: ", false);
  65.     emo_score += question_gen("Gets nervous easily: ", true);
  66.     open_score += question_gen("Is sophisticated in art, music, or literature: ", false);
  67.     extra_score += question_gen("Has an assertive personality: ", false);
  68.     open_score += question_gen("Is insightful, sees different possibilities: ", false);
  69.     agree_score += question_gen("Likes to cooperate with others: ", false);
  70.     con_score += question_gen("Is easily distracted: ", true);
  71.     open_score += question_gen("Has few artistic interests: ", true);
  72.  
  73.     cout << endl;
  74.     cout << "You have successfully completed the test!\n";
  75.     cout << "All scores range from 9-45, except Openness, which ranges from 18-90.\n";
  76.     cout << "Here are your scores:\n";
  77.     cout << "Extraversion: " << extra_score << endl;
  78.     cout << "Agreeableness: " << agree_score << endl;
  79.     cout << "Conscientiousness: " << con_score << endl;
  80.     cout << "Emotional Stability: " << emo_score << endl;
  81.     cout << "Openness: " << open_score << endl << endl;
  82.  
  83.     cout << "Thank you for taking the test.\n";
  84.     system("pause");
  85.  
  86.     return 0;
  87. }
  88.  
  89. int question_gen(string question, bool invert)
  90. {
  91.     int input(0);
  92.     bool valid(true);
  93.  
  94.     cout << question;
  95.     cin >> input;
  96.     if(input <=0 || input >=6)
  97.     {
  98.         valid = false;
  99.         while(!valid)
  100.         {
  101.             cout << "Please enter a valid answer (1-5): ";
  102.             cin >> input;
  103.             if(input >=1 && input <= 5) {valid = true;}
  104.         }
  105.     }
  106.  
  107.     if(invert == true)
  108.     {
  109.         if(input == 1) {input = 5;}
  110.         if(input == 2) {input = 4;}
  111.         if(input == 4) {input = 2;}
  112.         if(input == 5) {input = 1;}
  113.     }
  114.  
  115.     return input;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement