Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- using namespace std;
- int MathQ();
- int GeoQ();
- int main()
- {
- //identifier declaration
- int score1 = 0, score2 = 0, highM = 0, highG = 0;
- int option = 0;
- cout << "Would you like to play either the 1.Math Quiz or 2.Geography Quiz: ";
- cin>>option;
- if (option==1)
- {
- //call function
- score1 = MathQ();
- }
- else if (option==2)
- {
- //call function
- score2 = GeoQ();
- }
- else
- cout << "unknown";
- if(option==1)
- highM=score1;
- else if(option==2)
- highG=score2;
- //display score
- cout <<"Math Score: " <<highM <<endl;
- cout <<"Geography Score: " <<highG <<endl;
- return 0;
- }
- //---Fuction Definition
- int MathQ()
- {
- int ans, count = 0, score = 0;
- cout <<"2 + 2 = ";
- cin>>ans;
- if (ans == 4)
- {
- score+=10;
- count++;
- }
- cout <<"3 x 3 = ";
- cin>>ans;
- if (ans == 9)
- {
- score+=10;
- count++;
- }
- cout <<"10 / 2 = ";
- cin>>ans;
- if (ans == 5)
- {
- score+=10;
- count++;
- }
- cout << "Your Score is: " <<score <<endl;
- cout << "You have answered " <<count <<"questions correct." <<endl;
- return score;
- }
- int GeoQ()
- {
- int count = 0, score = 0;
- string ans;
- cout <<"What is the Capital of Pakistan?";
- cin>>ans;
- if (ans == "Islamabad")
- {
- score+=10;
- count++;
- }
- cout <<"What is the Capital of Florida?";
- cin>>ans;
- if (ans == "Tallahassee")
- {
- score+=10;
- count++;
- }
- cout <<"What is the Capital of Malaysia?";
- cin>>ans;
- if (ans == "Kuala Lumpur")
- {
- score+=10;
- count++;
- }
- cout << "Your Score is: " <<score <<endl;
- cout << "You have answered " <<count <<"questions correct." <<endl;
- return score;
- }
Add Comment
Please, Sign In to add comment