Millionaire Prgm.

I need some help with a program and was hoping if someone here knew how to do it in a quick way.

Here are the instructions:
Step 1: Find 11 questions of your choice with answers, then make-up 3 more choices for the multiple choice answers.

Step 2: Enter each question and four choices in the textfile in the format:
Questions
choice
choice
choice
choice
Question
choice
choice
choice
choice

etc.

Step 3: Make your game - allow the user to answer each question, and give the user a choice to either continue or quit while they're ahead.
The money amounts are as follows: $1000, $2000, $4000, $8000, $16000, $32000, $64000, $125000, $250000, $500000, $1000000

Step 4: No lifelines, but the user IS allowed the 50-50 option on any 3 questions.

Step 5: If they walk away with the money OR if they answer a question incorrectly, the game ends, and the user is informed of how much
moeny they've won.


Here is what I have so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <iostream>
#include <string>
#include <fstream>

using namespace std;
int main()
{
    string Questions[11] = {"Who was the first U.S.A President? ", "Which protozoan group consists of all parasites? ", "Who was the first man to go on the moon? ",
    "What is the real name of the lead guitarist in Guns N' Roses? ", "Who led the attack on the Twin Towers on 9/11? ", "What band sang the song 'Dream On'? ",
    "Who made the lightbulb? ", "Which president is on the $20 bill? ", "Which nucleotide is in mRNA but not in DNA? ", "Which war was first to be televised? ",
    "Which of the following did NOT happen during the Great Depression? "};
    string Choices1[11] = {"Abraham Lincoln", "Endospores", "Louis Armstrong", "Slash", "Muhammad Hossain", "ACDC", "Albert Einstein", "George Bush", 
    "Thymine", "Cold War", "Bank closures"};
    string Choices2[11] = {"Obama", "Skeptozoan", "Chuck Norris", "Angus Young", "Muhammad Ali", "Iron Maiden", "Aristotle", "Theodore Roosevelt", "Adenine", "Civil War", "Unemplloyment"};
    string Choices3[11] = {"John Adams", "Diatoms", "Bruce Lee", "Paul Johnson", "Al Qaeda", "Pillar", "Stephan Hawking", "John Adams", "Guanine", "Japanese War", "Lose of confidence"};
    string Answers[11] = {"George Washington", "Sporozoan", "Neil Armstrong", "Saul Hudson", "Osama Bin Laden", "Aerosmith", "Thomas Edison",
    "Andrew Jackson", "Uracil", "Vietnam War", "Disease spread"};
    string UserAnswer;
    char Continue;
    int Money = 0;
    ofstream Choices;
    
    Choices.open("Millionaire.txt", ios::app);
    cout << "Welcome to the Millionaire Game!!!" << endl << endl;
    
    for(int x = 0; x < 11; x++)
    {
            Choices << Questions[x] << endl;
            Choices << "A) " << Choices1[x] << endl;
            Choices << "B) " << Choices2[x] << endl;
            Choices << "C) " << Choices3[x] << endl;
            Choices << "D) " << Answers[x] << endl;
    }
    
    Continue = 'C';
    while(Continue == 'C')
    {
            cout << Questions[0] << endl;
            cout << "A) " << Choices1[0] << endl;
            cout << "B) " << Choices2[0] << endl;
            cout << "C) " << Choices3[0] << endl;
            cout << "D) " << Answers[0] << endl; 
            
            cout << "Enter your answer (A, B, C, or D): ";
            cin >> UserAnswer;
            if(UserAnswer == "D")
            {
                             cout << "Correct!" << endl;
                             Money = 1000;
                             cout << "You know have $" << Money << "!" << endl << endl;
            }
            else
            {
                             cout << "Incorrect!" << endl;
                             cout << "You have lost the game." << endl << endl;
                             break;
            }
            
            cout << "Do you want to continue or walk away (C/W)? ";
            cin >> Continue;
            
            Choices << Questions[1] << endl;
            Choices << "A) " << Choices2[1] << endl;
            Choices << "B) " << Answers[1] << endl;
            Choices << "C) " << Choices3[1] << endl;
            Choices << "D) " << Choices1[1] << endl;
            cout << "Enter your answer (A, B, C, or D): ";
            cin >> UserAnswer;
            if(UserAnswer == "D")
            {
                             cout << "Correct!" << endl;
                             Money = 1000;
                             cout << "You know have $" << Money << "!" << endl << endl;
            }
            else
            {
                             cout << "Incorrect!" << endl;
                             cout << "You have lost the game." << endl << endl;
                             break;
            }
            
            cout << "Do you want to continue or walk away (C/W)? ";
            cin >> Continue;
    }
    
    cout << "You have won $" << Money << endl;
    cout << "See you next time!" << endl << endl;

    system("PAUSE");
    return 0;
}

For starters, why don't you follow the instruction(s)?
steps 1&2 clearly states that you have to make a questions file, therefore the first few lines of your code in main() are supposed to be in an input file of some sort i.e
//input_data.txt
Who was the first U.S.A President?
Abraham Lincoln
Obama
John Adams
etc...


as for the actual program, try this flow perhaps:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// includes <iostream>/<vector>/<string>

// function to display questions and answers
void displayQ(std::vector<std::string>& q, /* other params, depending on the design */ );

// interract with the user, e.g the are you sure? is this your final answer
void askParticipant( /* any params deemed necessary */ );

// 50-50 option, MUST have according to the specs
void makeFiftyfifty( /* any params deemed necessary */  );

// winnings, MUST have, or perhaps a global member?
int countMoney( /* any params deemed necessary */ );

// menu/instructions/rules -should be the last coded
void menu();

int main()
{
     // declare variables
     // open file -probably a good idea to make a function for this, too ;)
     
     menu();
     
     // game loop, the while in your example is fine, perhaps a do-while?

    std::cout << "Your winnings are: " << countMoney << std::endl;
    return 0;
}
Just a suggestion: randomize the choices. D always being right will give a way a lot of money.
Topic archived. No new replies allowed.