[text] Zwhs

Viewer

  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int points = 0;
  9.     string answer;
  10.  
  11.     cout << "Welcome to this game! Answer the following questions to get points.\n";
  12.  
  13.     cout << "What color is the sky?\n";
  14.     cin >> answer;
  15.  
  16.     if (answer == "blue") {
  17.         points += 10;
  18.         cout << "Correct! You have earned 10 points.\n";
  19.     }
  20.     else {
  21.         cout << "Incorrect. The answer is blue.\n";
  22.     }
  23.  
  24.     cout << "What color are apples?\n";
  25.     cin >> answer;
  26.  
  27.     if (answer == "red") {
  28.         points += 10;
  29.         cout << "Correct! You have earned 10 points.\n";
  30.     }
  31.     else {
  32.         cout << "Incorrect. The answer is red.\n";
  33.     }
  34.  
  35.     cout << "You have earned a total of " << points << " points.\n";
  36.  
  37.     return 0;
  38. }

Editor

You can edit this paste and save as new:


File Description
  • Zwhs
  • Paste Code
  • 03 Feb-2023
  • 806 Bytes
You can Share it: