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

Writing a C++ board game Max number of players =20 3 arrays: names, boardspace (

ID: 3596052 • Letter: W

Question

Writing a C++ board game

Max number of players =20

3 arrays: names, boardspace (max25) and money (-4,000 to $50,000).

Two text files to randomly display on the board space (ex: good.txt and bad.txt). If good (open good.txt) and print “GREAT!” if bad (open bad.txt) and print "OH NO! ". Then randomly generate a number between 1 & 20 and use a for loop that iterates the number of times that was randomly generated in the step above. After the for loop, print out the line from the file.

SAMPLE OUTPUT OF PROGRAM RUNNING:

OU ARE PLAYING GAMENAME!

How many players? 2

PLAYER 1, WHAT IS YOUR NAME?

NAME: Name1

PLAYER 2, WHAT IS YOUR NAME?

NAME: Name2

Name1, PRESS ENTER TO ROLL DIE.

YOU ROLLED A 3.

Name1 IS NOW ON SPACE 3

GREAT! << output from file good.txt;

ADDED $2118.00 TO YOUR ACCOUNT.

YOU NOW HAVE $2118 .00 IN YOUR ACCOUNT.

Name2, PRESS ENTER TO ROLL DIE.

YOU ROLLED A 5.

Name2 IS NOW ON SPACE 5.

OH NO! << output from file bad.txt;

SUBTRACTED $5623.00 FROM YOUR ACCOUNT.

YOU NOW HAVE $ -5623.00 IN YOUR ACCOUNT.

Name1, PRESS ENTER TO ROLL DIE.

OU ROLLED A 6.

Name1 IS NOW ON SPACE 9.

OH NO! << output from file bad.txt;

SUBTRACTED $7731.00 FROM YOUR ACCOUNT.

YOU NOW HAVE $ -7731.00 IN YOUR ACCOUNT.

YOU FINISHED THE GAME NAME!!

PLAYER WHO SURVIVED ENTIRE GAME NAME BOARD : Name1

PLAYER WHO HAS THE MOST GAME NAME MONEY: Name2 has $ -30844 .00

DO YOU WANT TO PLAY AGAIN?

Y or N: n

Explanation / Answer

#include <iostream>

#include <cstring>

#include <iostream>

#include <stdlib.h>

using namespace std;

int main()

{

int noOfPlayers,bigVal;

string[] names;

int[] money;

int[] boardSpace;

char playMood;

int i,j,memberValue;

cout<<"enter the no.of players:";

cin>>noOfPlayers;

while(1)

{

cout<<"Do you want to play again:(y or n)";

cin>>playMood;

switch(playMood)

{

case 'y':

for(i=0;i<noOfPlayers;i++)

{

cout<<"Enter the "<<i<<" player name:";

cin>>names[i];

cout<<"roll the dice:";

boardSpace[i] = rand() % 25 + 1;

cout<<"You rolled a:"<<boardSpace[i];

if(boardSpace[i] == 0)

{

std::ifstream inFile;

inFile.open("C:UsersLenovoDesktopad.txt");

while(!inFile.eof())

{

//Get bad

inFile >> bad;

//Print bad

std::cout << bad;

}

//Close file

inFile.close();

cout<<"Subtracted $250 from your account";

money[i] = -250;

cout<<"you now have -$250 on your account"

}//if

else

{

std::ifstream inFile;

inFile.open("C:UsersLenovoDesktopgood.txt");

while(!inFile.eof())

{

//Get input

inFile >> good;

//Print input

std::cout << good;

}

//Close file

inFile.close();

cout<<"Added $500 on your account";

money[i] = 500;

cout<<"you now have $500 on your account";

}

}//for

cout<<"You finished the game:";

break;

case 'n':

break;

}//switch

for(int j=0;j<noOfPlayers;j++)

{

if(money[j]>money[j+1])

{

bigVal = money[j];

memberValue = j;

}

else

{

bigVal = money[j+1];

memberValue = j+1;

}

}

cout<<"PLAYER WHO SURVIVED ENTIRE GAME NAME BOARD"<<names[memberValue];

cout<<"He Gain the amount:$"<<bigVal;

if(playMood == 'n')

{

exit;

}

}//while

return 0;

}//main

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

Thanku