Question: Could Someone help me with this assignment? I think I have up to the 4th step in the program. I'll post my code if needed.
Could Someone help me with this assignment? I think I have up to the 4th step in the program. I'll post my code if needed.
Hacking into and comprising an organizations networks has become a very serious issue.
Therefore, management has asked you to create and execute a program which simulates hacking activity over a certain timeframe. The program must only use pointers to access any arrays. You are not allowed to use array indexes
A sample execution of the program is as follows :
Enter the number of the web servers: 6
Enter the number of hours to simulate: 5
Hacking attempts per hour:
Hour Server1 Server2 Server3 Server4 Server5 Server6
0 0 0 0 0 0 0
1 4 1 0 7* 5 2
2 2 3 4* 1 0 2
3 0 3 1 4* 3 1
4 1 4 5* 1 5* 3
5 5* 2 3 2 0 4
Total 12 13 13 15* 13 12
Project 4 - Pseudocode
1. Prompt user for number of servers and hours
2. Accept user input
3. Create a dynamic array for the servers and one for the totals (See example 12-6)
4. Call initialize function.
5. Output heading lines and the zero hour line
6. Loop through hours of the simulation
6a. Loop through each server assigning number of hack attempts (call rand_set)
6b. Determine pointer value to highest number of hack attempts (part of rand_set)
6c. Output an hours line of information. (call print)
7. Output the total line.
Next Page
Some if the identifiers needed are :
int server_count; // number of servers
int *highest_attempts; // pointer to highest number in
// server array
int *last; // pointer to last value in array
Suggested functions are :
initialize: Function that places zeros in all elements of the arrays. It also calls srand to initialize the random number seed, sets the value of highest-attempts to NULL and appropriately initializes last based on size.
print: Prints the values in the array. print first goes to a new line. It then prints each array value with spaces before and after. It prints the element pointed to by highest_attempts with an * after.
rand_set: Randomly assigns a value to an element in the server array. highest_attempts is appropriately changed.
These functions should all work properly if server_count is changed.
NOTE : Example 5-6 on the textbook for an explanation of how to generate a random number.
Here is a sample program that generates random numbers between 0 and 9:
#include
#include
#include
using namespace std;
int main( )
{
int i;
srand (time(NULL));
for(int j = 0; j < 5; j++)
cout << rand() % 10 << " ";
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
