1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#include <iostream>
#include <array>
#include <string>
#include <vector>
struct Card {
std::string question;
std::array<std::string,4> answers;
char solution=0;
double points=0;
};
int main(){
std::vector<Card> cards;
cards.push_back(Card{"How many rings are there on the Olympic flag?", {"0","4","5","7"}, 'c', 100.0});
cards.push_back(Card{"How many holes are on a standard bowling ball?", {"2","3","5","10"}, 'b', 200.0});
cards.push_back(Card{"How many points is the letter X worth in English-language Scrabble?", {"0","8","10","11"}, 'c', 300.0});
cards.push_back(Card{"Which of these animals does NOT appear in the Chinese zodiac?", {"Bear","Rabbit","Dragon","Dog"}, 'd', 400.0});
cards.push_back(Card{"What is a pomelo?", {"An old-fashioned punching bag","A breed of dog","The largest citrus fruit","Something that cheerleaders hold"}, 'c', 500.0});
double totalPoints = 0;
for(const Card& card : cards) {
std::cout << card.points << " points question:\n";
std::cout << card.question << "\n";
std::cout << "a: " << card.answers[0] << "\n";
std::cout << "b: " << card.answers[1] << "\n";
std::cout << "c: " << card.answers[2] << "\n";
std::cout << "d: " << card.answers[3] << "\n";
cout << "Enter your answer in lower case letter: " << endl;
char userAnswer;
std::cin >> userAnswer;
if(userAnswer == card.solution) {
totalPoints += card.points;
std::cout << "Correct! You get " << card.points << " points!\n";
} else {
std::cout << "Wrong!\n";
break;
}
std::cout << "\n\n";
}
std::cout << "You get total of " << totalPoints << " points!\n";
return 0;
}
|