
May 5th, 2008, 09:30 PM
|
|
Registered User
|
|
Join Date: Feb 2008
Posts: 10
Time spent in forums: 2 h 40 m 8 sec
Reputation Power: 0
|
|
|
Help with jeopardy program
it works but not as intended. i have no clue what to do
Code:
#include <iostream>
#include <fstream>
#include <ctime>
#include <cstdlib>
#include <string>
using namespace std;
const int NUM=10;
int main()
{
ifstream questionfile("QUESTIONS.txt");
ifstream answerfile("ANSWERS.txt");
string answer[NUM], question[NUM], inquestion;
string input;
srand( time(NULL));
//----------get information--------------//
for (int m=0; m<NUM; m++)
{
getline(questionfile, question[m]);
getline(answerfile, answer[m]);
}
questionfile.close ();
answerfile.close ();
for(int r=0; r<10; r++)
{
int theDice = ( rand() % 10) +1;
cout<<question[theDice]<<endl;
answer[theDice];
cout<<"Response: ";
cin>>inquestion;
if (inquestion == answer[theDice])
cout<<"correct"<<endl;
else
cout <<"WRONG"<<endl;
}
return 0;
}
what i get is
Code:
/*
This Phil Collin song was surrounded by an urban ledgend.
Response: what is in the night
WRONG
This Phil Collin song was surrounded by an urban ledgend.
Response: WRONG
This was the most important event in WW2 that eventually lead the allies to vict
ory.
Response: WRONG
This Mel Brooks film was the first movie to have people fart on film.
Response: WRONG
This actor is well known for his religion and his clip on Oprah.
Response: WRONG
This Mel Brooks film was the first movie to have people fart on film.
Response:
*/
Thank you in advanced
|