Wednesday, 28 September 2016

Murder Case Game Program Code in C++










#include<iostream>
#include<string>
#include<stdlib>

using namespace std;

int main()
{
    int ans1, ans2, ans3;
    int answer;

    cout << "\n Who killed Mr. Boddy! \n 1. Ms. Scarlet,\n 2. Colonel Mustard,\n 3. Mrs. White \n 4. Mr. Green,\n 5. Mrs. Peacock,\n 6. Professor Plum \n\n ";
    cin >> ans1;
    int i=1;
    while(i<7) {
        answer = rand() % i + 1;
        i++;
    }
    cout<<"\n The right answer is option  : "<<answer;
    if(answer==ans1)
        cout<<"You've done it! You've solved the case!";
    switch(answer) {
    case 1:
        cout<<" It was Ms. Scarlet \n ";
        break;
    case 2:
        cout<<"It was Colonel Mustard \n ";
        break;
    case 3:
        cout<<"It was Mrs. White \n !";
        break;
    case 4:
        cout<<"It was Mr. Green \n ";
        break;
    case 5:
        cout<<"It was Mrs. Peacock \n";
        break;
    case 6:
        cout<<"It was Professor Plum \n";
        break;
    default:
        cout<<"Sorry! Invalid Choice! ";
    }

    cout << "\n What Weapon Was Used? \n \n 1. Candlestick \n 2. Knife  \n 3. Lead pipe \n 4. Revolver \n 5. Rope \n 6. Wrench";
    cin >> ans2;
    i=1;
    while(i<7) {
        answer = rand() % i + 1;
        i++;
    }
    cout<<"\n The right answer is option  : "<<answer;
    if(ans2==answer)
        cout<<"You've done it! You've solved the case!";
    switch (answer) {
    case 1:
        cout<<" It was by  Candlestick \n ";
        break;
    case 2:
        cout<<"It was by Knife \n ";
        break;
    case 3:
        cout<<"It was by Lead pipe \n !";
        break;
    case 4:
        cout<<"It was by  Revolver \n ";
        break;
    case 5:
        cout<<"It was by  Rope  \n";
        break;
    case 6:
        cout<<"It was by  Wrench  \n";
        break;
    default:
        cout<<"Sorry! Invalid Choice! \n";
    }

    cout << "\n Where was Mr. Boddy Killed? \n \n 1. Lounge \n 2. Humanities Building \n 3. Parking Lot \n 4. Kitchen \n 5. Ball room  \n 6. Conservatory \n 7. Billiard room \n 8. Library 9. Study room \n  ";
    cin >> ans3;
    i=1;
    while(i<10) {
        answer = rand() % i + 1;
        i++;
    }
    cout<<"\n The right answer is option  : "<<answer;
    if(ans3==answer)
        cout<<"You've done it! You've solved the case! \n";
    switch (answer) {
    case 1:
        cout<<" at 1. Hall \n ";
        break;
    case 2:
        cout<<"at 2. Loung \n ";
        break;
    case 3:
        cout<<"at 3. Dining room \n ";
        break;
    case 4:
        cout<<"at 4. Kitchen \n ";
        break;
    case 5:
        cout<<"at 5. Ball room \n";
        break;
    case 6:
        cout<<"at 6. Conservatory \n";
        break;
    case 7:
        cout<<"at 7. Billiard room \n";
        break;
    case 8:
        cout<<"at 8. Library \n";
        break;
    case 9:
        cout<<"at 9. Study room \n ";
        break;
    default:
        cout<<"Sorry! Invalid Choice! \n ";
    }
    return 0;
}

No comments:

Post a Comment