Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a game that picks a suspect at random and the player must guess the suspect and evidence. You must follow the following requirements. 1.

Create a game that picks a suspect at random and the player must guess the suspect and evidence. You must follow the following requirements.

1. Start your program with a welcome message printed to console with your name, the program name and purpose of the program.

2. Create an array with 10 slots (one per suspect value a list of names you made up each programmers list should be unique). The slots can contain an integer showing the suspects inmate number (easier, cannot earn an A or A+) or a string showing the name. Remember in C, a string is an array of characters.

3. Create a second array with 5 slots for the evidence. Again, I expect your list to be unique. The slots can contain an integer showing the items evidence number (this is easier, but cannot earn an A or A+) or a string showing the name. Remember in C, a string is an array of characters.

4. Use the rand() function from the math library (#include ) to randomly select the index of the suspect and item of evidence. You can show these on the screen when you are testing your program, but comment the code to show the suspect and evidence when you submit your program. Include a comment identifying the line.

5. Use a for loop to go through the suspects array and print the list of suspects the user is guessing from. The list must use the array to print.

6. Ask the user to enter a number/letter/word to guess the suspect they think did the crime. The last item on the menu should be an option to quit. Read the input using scanf().

7. If the user quits, the program should end with a message thanking them for using the program.

8. If the user does not guess the correct suspect, the program should tell them it is wrong and invite them to try again. Then the program should end with a message thanking them for using the program.

9. If the user correctly selects the secret guilty suspect: a. Show the evidence list and ask them to guess the evidence used by the suspect in the crime. b. Use the array of evidence and a for loop to display the list of evidence. The last item should be the option to quit. c. Use scanf() to read their input. d. If the user quits, the program should end with a message thanking them for using the program. e. The program should show the evidence and suspect selected by the user on one line.f. If the user does not guess the correct evidence, the program should tell them it is wrong and invite them to try again. The program should end. g. If the user guesses the correct suspect and evidence, the program should congratulate them for winning. Then the program should end with a message thanking them for using the program.

10. When the user enters values that are invalid (suspect is not a suspect, evidence is not a evidence) make sure the exit is graceful. The program should give an error message and end with the normal exit message.

Here is the code I have so far for my c++ program. Can anyone please help me finish this I cannot seem to figure out how to code the rest of this program? If there is anything that needs to be adjusted in my program feel free to fix it.

#include

#include

#include

#include

#include

using namespace std;

int main(int argc, char* argv[])

{

cout << "Welcome to the Who Dunnit Game. My name is Abdul Osumah and I am the creator of this game. The purpose of this program is to create a game where the player has to pick a suspect and evidence. They have to figure out who committed the crime." << endl << endl; // The game welcoming message and purpose

cout<< "Here are the suspect values" << endl; //Inmate numbers

int name[10]= {1,2,3,4,5,6,7,8,9,10};

cout << name[0] << endl;

cout << name[1] << endl;

cout << name[2] << endl;

cout << name[4] << endl;

cout << name[5] << endl;

cout << name[6] << endl;

cout << name[7] << endl;

cout << name[8] << endl;

cout << name[9] << endl <

cout<< "Here are the evidence values" << endl; //Evidence numbers

int evidence[5]= {11,12,13,14,15};

cout << evidence[0] << endl;

cout << evidence[1] << endl;

cout << evidence[2] << endl;

cout << evidence[3] << endl;

cout << evidence[4] << endl <

cout<< "Here are the random suspect values" << endl; //Random Inmate suspects

int rand();

for(int x= 1; x<=10; x++);

cout<< (rand() %10) +1 << endl;

cout<< (rand() %10) +1 << endl;

cout<< (rand() %10) +1 << endl;

cout<< (rand() %10) +1 << endl;

cout<< (rand() %10) +1 << endl;

cout<< (rand() %10) +1 << endl;

cout<< (rand() %10) +1 << endl;

cout<< (rand() %10) +1 << endl;

cout<< (rand() %10) +1 << endl;

cout<< (rand() %10) +1 << endl << endl;

cout<< "Here are the random evidence values" << endl; //Random evidence numbers

int rand();

for(int x= 2; x<=15; x++);

cout<< (rand() %20) +2 << endl;

cout<< (rand() %20) +2 << endl;

cout<< (rand() %20) +2 << endl;

cout<< (rand() %20) +2 << endl;

cout<< (rand() %20) +2 << endl <

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions