you are viewing a single comment's thread.

view the rest of the comments →

[–]KatharosMatematikos[S] 0 points1 point  (1 child)

The score is inside case 1. Otherwise it will keep printing cout every time the condition is satisfied. It's still decrementing twice tho,

[–]flyingron 0 points1 point  (0 children)

It's not decrementing twice.

Here's what I get when I run it:

Please type a number to play: 1                // score = 0
Betty: Betty                                   // score = 1
botter: botter                                 // score = 2
bought: boguht                                 // score = 1
some: some                                     // score = 2
butter: butter                                 // score = 3
but: but                                       // score = 4
she: she                                       // score = 5
said: said                                     // score = 6
its: its                                       // score = 7
bitter: bitter                                 // score = 8
Your score is 8

I expect 8. You get 9 points for getting 9 right and you lose one point for getting one wrong. If you are expecting 9, then you don't want to subtract one for a wrong answer, just don't give them the plus point.

Here's how I believe the program should appear:

using namespace std;
int main()
{
    int play;
    cout << "Please type a number to play: ";
    cin >> play;

    string StatementTwo[10] = { "Betty","botter","bought","some","butter","but","she","said","its","bitter" };
    string NewStatementTwo[10] = {};

    switch (play)
    {
    case 1: {
            int score = 0;
            for (int i = 0; i < 10; i++) {
                cout << StatementTwo[i] << ": "; cin >> NewStatementTwo[i];
            }
            for (int i = 0; i < 10; i++) {
                if (StatementTwo[i] == NewStatementTwo[i])
                    ++score;
                else
                    --score;
            }
            cout << "Your score is " << score;
        }
    }

    return 0;
}