Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <cstdio>
- #include <random>
- #include <set>
- // These three "#include" statements are for the rand() code.
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- int userScore = 0;
- int random1To20();
- int random1To20()
- {
- int targetNumber1;
- int least = 1;
- int most = 20;
- targetNumber1 = rand() % most + least;
- return targetNumber1;
- }
- int indicateAnswer();
- int pointRound();
- void text()
- {
- int respnse;
- cout << "Your score is " << userScore << endl;
- cout << "Decide whether " << random1To20 << " is one of the multiples or is not a muliple at all " << endl;
- cout << "a. The number is a multiple of 2. " << endl;
- cout << "b. The number is a multiple of 3. " << endl;
- cout << "c. The number is a multiple of both 2 and 3. " << endl;
- cout << "d. None of these are true. " << endl;
- char response;
- cin >> response;
- return response;
- }
- char totalUpRightAnswers(int points)
- {
- if (points % 2 == 0 && points % 3 == 0)
- {
- return 'c';
- }
- else if (points % 2 == 0)
- {
- return 'a';
- }
- else if (points % 3 == 0)
- {
- return 'b';
- }
- else
- {
- return 'd';
- }
- }
- bool processUserGuess(int points, char userAnswer)
- {
- char correctness = totalUpRightAnswers(points);
- return (userAnswer == correctness);
- }
- int pointRound()
- {
- int points = random1To20();
- char answer = indicateAnswer(points);
- bool correctness = processUserGuess(points, answer);
- // This if statement is for make scoring for the correct answer.
- if (correctness)
- {
- cout << "You are right!";
- return 1;
- }
- else
- {
- cout << "Oh no, you are wrong.";
- return -1;
- }
- }
- int main()
- {
- userScore = 0;
- const int highestScore = 10;
- srand(time(NULL));
- do{
- cout << "Your scroe is " << userScore << endl;
- userScore += pointRound();
- } while (userScore < (highestScore)
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement