Public feed #379420

Miscellany

public text v1 · immutable
Raw Edit
·published 2007-03-03 06:56 UTC
rendered paste body
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
using namespace std;

// required for conversion to lowercase
class toLower {public: char operator() (char c) const {return tolower(c);}};

int main()
{
  string answer;
  int score = 0;

  cout << "(1) What year was the Declaration of Independence drafted? ";
  getline(cin, answer);
  transform(answer.begin(), answer.end(), answer.begin(), toLower());

  if (answer == "1776") {
    cout << "Correct\n";
    score++;
  }
  else {
    cout << "Incorrect\n";
  }


  cout << "\n(2) In 1776 who was chosen by the Committee of Five to write the Declaration of Independence? ";
  getline(cin, answer);
  transform(answer.begin(), answer.end(), answer.begin(), toLower());

  if (answer == "thomas jefferson") {
    cout << "Correct\n";
    score++;
  }
  else {
    cout << "Incorrect\n";
  }


  cout << "\n(3) At the signing of the Declaration of Independence who was quoted saying \"We must all hang together, or assuredly we shall all hang separately\"? ";
  getline(cin, answer);
  transform(answer.begin(), answer.end(), answer.begin(), toLower());

  if (answer == "benjamin franklin") {
    cout << "Correct\n";
    score++;
  }
  else {
    cout << "Incorrect\n";
  }

  cout << "\nYou answered " << score << " Correctly out of 3\n";

  return 0;
}