Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Each c/c++ project must contain one and only one main function. You may solve bo

ID: 3832946 • Letter: E

Question

Each c/c++ project must contain one and only one main function. You may solve both part 1 and 2 in one project with one main() function, or submit two projects, one for part 1 and the other for part 2. Part 1 Random CLUE Speculations clue is a popular murder-mystery board game. The game is to collect clues to deduce which suspect murdered the game's perpetual victim (Mr. Boddy), with which weapon, and in what room At the beginning of play, one suspect, one weapon, and one room card are secretly chosen to represent the facts of the murder. These three cards are put into a special envelope in the "Cella The rest of the cards are distributed among the players. The six (6) murder suspects are: 1. Ms. Scarlet 2. Colonel Mustard 3. Mrs. White 4. Mr. Green 5. Mrs. Peacock 6. Professor Plum The six (6) possible murder weapons are: 1. Candlestick 2. Knife 3. Lead pipe 4. Revolver 5. Rope 6. Wrench There are nine (9) rooms in the mansion: 1. Hall 2. Lounge 3. Dining Room 4. Kitchen 5. Ballroom 6. Conservatory 7. Billiard Room 8. Library 9. Study

Explanation / Answer

/*
C++ program that generates 15 random suggestions for murder
mystery. The user is prompted to enter one guess correct to suggestions
.If user guess is correct then print correct guess otherwise print
wrong guess. The progarm contiues until user enters n to stop
*/
//guess.cpp
//include header files
#include<iostream>
#include<time.h>
#include<string>
using namespace std;
int main()
{

   const int ROWS=6;
   const int SIZE=20;
   srand(time_t(0));
   int userinput;
   int cont=1;
   string choice;

   //array of suspects
   string suspects[ROWS]={"Ms. Scarlet",
       "Colonel Mustard",
       "Mrs. White",
       "Mr. Green",
       "Mrs. Peacock",
       "Professor Plum"};
   //array of weapons
   string weapons[ROWS]={"Candlestick",
       "Knife",
       "Lead pipe",
       "Revolver",
       "Rope",
       "Wrench"};

   //array of rooms
   string rooms[9]={"Hall",
       "Lounge",
       "Dining Room",
       "Kitchen",
       "Ballroom",
       "Conservatory",
       "Billiard Room",
       "Library",
       "Study"};

   //set correct suggestion
   string correctSuggestion ="I suggest it was Mrs. Peacock, in the Kitchen, with the Lead pipe";
   string userSuggestion;
   int randSuspect;
   int randWeapon;
   int randRooms;
   int i;

   string suggestions[15];

   //generate 15 suggestions
   for(i=0;i<15;i++)
   {

       randSuspect=rand()%ROWS;
       randWeapon=rand()%ROWS;
       randRooms=rand()%9;
       suggestions[i]="I suggest it was "
           +suspects[randSuspect]+", in the "+
           rooms[randRooms]+", with the "+weapons[randWeapon];

       cout<<(i+1)<<" ."<<suggestions[i]<<endl;
   }

   /*Continue until user enters n to stop*/
   while(cont)
   {

       do
       {
           cout<<"Select one suggestion [1-15] :";
           cin>>userinput;

           if(userinput<0 || userinput>15)
               cout<<"Invalid selection "<<endl;

       }while(userinput<0 || userinput>15);

       userSuggestion=suggestions[userinput];

       //check for comparision
       if(strcmp(correctSuggestion.c_str(),userSuggestion.c_str())==0)
           cout<<"Right guess"<<endl<<endl;
       else
           cout<<"Wrong guess"<<endl<<endl;


       cout<<"Do you want to continue [y /n]";
       //read choice
       cin>>choice;

       if(choice=="n")
           cont=0;

   }
   system("pause");
   return 0;
}

---------------------------------------------------------------------

Sample output:

1 .I suggest it was Mrs. White, in the Library, with the Revolver
2 .I suggest it was Colonel Mustard, in the Library, with the Wrench
3 .I suggest it was Colonel Mustard, in the Lounge, with the Wrench
4 .I suggest it was Ms. Scarlet, in the Dining Room, with the Revolver
5 .I suggest it was Mrs. White, in the Study, with the Wrench
6 .I suggest it was Mr. Green, in the Conservatory, with the Wrench
7 .I suggest it was Mr. Green, in the Billiard Room, with the Rope
8 .I suggest it was Colonel Mustard, in the Ballroom, with the Knife
9 .I suggest it was Colonel Mustard, in the Hall, with the Revolver
10 .I suggest it was Mrs. White, in the Ballroom, with the Wrench
11 .I suggest it was Mrs. Peacock, in the Kitchen, with the Lead pipe
12 .I suggest it was Professor Plum, in the Billiard Room, with the Wrench
13 .I suggest it was Colonel Mustard, in the Hall, with the Wrench
14 .I suggest it was Mr. Green, in the Dining Room, with the Knife
15 .I suggest it was Professor Plum, in the Library, with the Knife
Select one suggestion [1-15] :1
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :6
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :9
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :12
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :7
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :8
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :9
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :3
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :1
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :14
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :13
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :12
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :11
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :11
Wrong guess

Do you want to continue [y /n]y
Select one suggestion [1-15] :10
Right guess

Do you want to continue [y /n]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote