<p>After i am done creating a weapons menu; if the user chooses flame thrower or
ID: 3640967 • Letter: #
Question
<p>After i am done creating a weapons menu; if the user chooses flame thrower or bow and arrow, a practice session starts in which the computer will randomly generate a number from 1-4 which will determine what target is hit.</p><p>Assign the following point values:</p>
<p>1- Target A is hit, worth 100 points</p>
<p>2- Target B is hit, worth 200 points</p>
<p>3- Target C is hit, worth 300 points</p>
<p>4- No target is hit, 0 points</p>
<p>If the user chooses Magic; heshe will make a potion. The computer randomly generates a number from 0-1 to determine if its successful. 200 points if it successful, 100 points will be deducted if it fails.</p>
<p>At the end dispaly users score</p>
<p> </p>
<p>Can anyone please help me with this? please!!!<br /><br /></p>
Explanation / Answer
#include <iostream>
#include <time.h> //need for time(NULL) (seeding random function)
using namespace std;
//PROTOTYPES
int nextRandom(int min, int max);
int main()
{
//LOCAL DECLARATIONS
int test14;
int test01;
srand((unsigned)time(NULL)); //include this line before calling any random function
//check nextRandom function
for (int i = 0; i < 20; i++)
cout << nextRandom(1,4) << " ";
cout << endl;
for (int i = 0; i < 20; i++)
cout << nextRandom(0,1) << " ";
cout << endl;
//Your implementation
test14 = nextRandom(1,4);
if (test14 == 1)
{
//1..
}
else if (test14 == 2)
{
//2..
}
else if (test14 == 3)
{
//3..
}
else
{
//4..
}
//test14 = nextRandom(1,4);
//test14 = nextRandom(1,4);
//...
test01 = nextRandom(0,1);
if (test01 == 0)
{
//0..
}
else
{
//1..
}
//test01 = nextRandom(0,1);
//test01 = nextRandom(0,1);
//...
return 0;
}
//---------------------------------------------------------
// FUNCTION DEFINITIONS
//---------------------------------------------------------
int nextRandom(int min, int max)
{
return rand() % (max - min + 1) + min;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.