140k views
5 votes
In your CSC1300LAB folder, create a Lab9 folder. 2. Open Visual Studio Code (VS Code). 3. Click on File and then select Open Folder. Select the folder that you just created. 4. Create a source file named lab9.cpp. 5. Make sure to put a comment block at the top of your code with the filename, author (you \& your partner or just you), date, and purpose of the program. Also make sure to put in comments to identify major sections of your code. MAIN FUNCTION Variables in the Main Function - An int to hold the number of investigators (I refer to it in this assignment as being named numInvestigators) - An int to hold the total number of recordings of all investigators. - A double to hold the average number of recordings. - An int to hold the index of the investigator that had the largest amount of recordings. - A char array of size 100, which will hold the name of the haunted location that was investigated. - A pointer to an int, which will eventually point to an array that will hold the number of recordings each investigator had. - A pointer to a string, which will eventually point to an array that will hold the name of each investigator. - A pointer to a string, which will eventually point to an array that will hold the date that the investigator made the recordings (performed their investigation). Main Function Directions - Ask the user for the location the are investigating and read in the user's input to the character array (c-string). - Ask the user for the number of investigators at the location and read it into the integer variable. - Validate that the number entered is at least 1 but not greater than 25. - Dynamically allocate (syntax below) the three arrays - an integer array holding the number of recordings (evps), a string array holding the names of the investigators, and a string array holding the date of their investigation. intPtr = new int[numInvestigators]; //intptr is the name of the integer pointer parameter - Call the getParanormalData function, sending the number of investigators and the three pointers that point to the three arrays. - Call the getStats function, sending the number of investigators, the pointer to the int array, the memory address of the total (int) variable, the memory address of the average (double)variable, and the memory address of the highest index (int) variable. - Print the results to the screen in a nice, readable way like the sample output. (Remember to access arrays using pointer notation) - Release the three dynamically allocated arrays. Note the arrays were created in the "createArrays" function, but it isn't until the end of the main function that we are done with the arrays so this is where the memory should be released. To release an array you use the following syntax: delete [] ptrName; //ptrName is the pointer that holds the memory address of the array PROGRAMMER-DEFINED FUNCTIONS getParanormalData Return type: void Parameters: - An int holding the number of investigators (numlnvestigators). - A pointer to an int, which points to an array that holds the number of recordings each investigator had (evps) - A pointer to a string, which points to an array that holds each investigator name. - A pointer to a string, which points to an array that holds the dates of investigation Purpose: this function will iterate through each element of the array and allow the user to enter in each investigator's name, day of investigation, and number of EVPs. NOTE: Accessing arrays must be in pointer notation! getStats Return type: void Parameters: - An int holding the number of investigators (numlnvestigators) - A pointer to an int, which points to an array that holds the number of recordings (evps) each investigator had. - A pointer to an int to hold the memory address of the total variable from main - A pointer to a double to hold the memory address of the average variable from main - A pointer to an int to hold the memory address of the index of the investigator with the most recordings (highestindex) variable from main Purpose: this function will find the total number of recordings of EVPs by all investigators and the index of the investigator that had the most recordings (highestIndex). Then it willfind the average number of recordings by the investigators. NOTE: Accessing arrays must be in pointer notation!

User Mike Bynum
by
8.6k points

1 Answer

4 votes

Final answer:

This question is about creating a program in C++ for paranormal investigations and calculating statistics based on the entered data.

Step-by-step explanation:

The subject of this question is Computers and Technology.

This question is about creating a program in C++ that will store and process data related to paranormal investigations. The program will prompt the user to enter information about the investigators and their recordings. It will then calculate statistics, such as the total number of recordings and the investigator with the most recordings.

The main functions of the program are:

  1. getParanormalData: This function prompts the user to enter information about the investigators and their recordings.
  2. getStats: This function calculates statistics based on the entered data, such as the total number of recordings and the investigator with the most recordings.
User Munawwar
by
8.2k points