Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- #include <string>
- #include "det_answers.h"
- using namespace std;
- string choose_question(int x);
- int det_answers(int x);
- string get_answer(int x, int y);
- int main() //Main function that sets the rules of the game//
- {
- int correct_answers=0;
- int money=10;
- int tries=3;
- int questions=0;
- int *ptr;
- string question_components[10][2];
- string input_answer;
- int x=0;
- srand(time(0));
- x=((rand()%9));
- ptr=&x;
- cout<<"***************WELCOME TO WHO WANTS TO BE A MILLIONARIE!!!*****************\n\n";
- for(int r=0;r<10;r++)
- {
- for(int t=0;t<2;t++)
- {
- question_components[r][t]='0';
- }
- }
- while(questions<8 && tries>0)
- {
- int y=0;
- x++;
- if (x>9)
- {
- x=0;
- }
- question_components[*ptr][0]=choose_question(x);
- y=det_answers(x);
- cout<<question_components[*ptr][0]<<endl;
- question_components[x][1]=get_answer(x,y);
- cout<<"Choose an answer: ";
- cin>>input_answer;
- if( question_components[*ptr][1]==input_answer)
- {
- cout<<"Correct"<<endl;
- questions++;
- money=money*10;
- cout<<"You have gotten $"<<money<<" Congrats!"<<endl<<endl;
- }
- else
- {
- cout<<"Incorrect"<<endl;
- tries--;
- cout<<"You have "<<tries<<" lives remaining"<<endl<<endl;
- }
- }
- if(tries==0)
- {
- cout<<"YOU'VE LOST >_>";
- }
- else
- {
- cout<<"YOU'VE WON "<<money;
- }
- return 0;
- }
- string choose_question(int x) //Function randomly chooses a question//
- {
- string question_num[10];
- string question;
- question_num[0]="Modern football is said to have evolved from?\n";
- question_num[1]="What is the Intelligence agency of UK?\n";
- question_num[2]="Name the nuclear plant that closed for ever in Ukrain.\n";
- question_num[3]="Which football club does Cristiano Ronaldo play for?\n";
- question_num[4]="Which mosque is the biggest in the world?\n";
- question_num[5]="What is the Japanese word for Goodbye?\n";
- question_num[6]="There is only one continent on the earth that \ndoesn't have any deserts. Which is that continent?\n";
- question_num[7]="What is the color of an emerald?\n";
- question_num[8]="Where is the Changi International Airport located?\n";
- question_num[9]="What am I going to get for this Project?\n";
- return question_num[x];
- }
- int det_answers(int x); //Calls external function to determine the answer/
- string get_answer(int x, int y) //Retrieves answers based on question generated//
- {
- string multiple_choice[4];
- string answer;
- if(x==0)
- {
- multiple_choice[0]="a) England";
- multiple_choice[1]="b) India ";
- multiple_choice[2]="c) France";
- multiple_choice[3]="d) Canada";
- answer="a";
- }
- else if(x==1)
- {
- multiple_choice[0]="a) MI6 ";
- multiple_choice[1]="b) MI5";
- multiple_choice[2]="c) CIA";
- multiple_choice[3]="d) LOL";
- answer="b";
- }
- else if(x==2)
- {
- multiple_choice[0]="a) Kuala Lumpur";
- multiple_choice[1]="b) Nicaragua";
- multiple_choice[2]="c) Chernobyl";
- multiple_choice[3]="d) Texas";
- answer="c";
- }
- else if(x==3)
- {
- multiple_choice[0]="a) Juventus";
- multiple_choice[1]="b) Real Madrid";
- multiple_choice[2]="c) Manchester United";
- multiple_choice[3]="d) Barcelona";
- answer="a";
- }
- else if(x==4)
- {
- multiple_choice[0]="a) Federal Territory Mosque";
- multiple_choice[1]="b) Al-Aqsa Mosque";
- multiple_choice[2]="c) The Prophet's Mosque";
- multiple_choice[3]="d) Al-Haram Mosque";
- answer="d";
- }
- else if(x==5)
- {
- multiple_choice[0]="a) Au revoir";
- multiple_choice[1]="b) Goodbye";
- multiple_choice[2]="c) Sayonara";
- multiple_choice[3]="d) Arrivederci";
- answer="c";
- }
- else if(x==6)
- {
- multiple_choice[0]="a) Europe";
- multiple_choice[1]="b) North America";
- multiple_choice[2]="c) Africa";
- multiple_choice[3]="d) Asia";
- answer="a";
- }
- else if(x==7)
- {
- multiple_choice[0]="a) Yellow";
- multiple_choice[1]="b) Red";
- multiple_choice[2]="c) Blue";
- multiple_choice[3]="d) Green";
- answer="d";
- }
- else if(x==8)
- {
- multiple_choice[0]="a) Vietnam";
- multiple_choice[1]="b) Thailand";
- multiple_choice[2]="c) Taiwan";
- multiple_choice[3]="d) Singapore";
- answer="d";
- }
- else if(x==9)
- {
- multiple_choice[0]="a) 100%";
- multiple_choice[1]="b) 100%";
- multiple_choice[2]="c) 100%";
- multiple_choice[3]="d) 100%";
- answer="a";
- }
- for(int i=0;i<4;i++)
- {
- cout<<multiple_choice[i]<<endl;
- }
- return answer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement