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

My assignment is to write a C++ program which will automatically compute the che

ID: 3763811 • Letter: M

Question

My assignment is to write a C++ program which will automatically compute the checksum on a specified data file, and then store that checksum in an unsigned integer array. The program must also store the file name in another, parallel array. You can use these declarations in your program:

const int SUM_ARR_SZ = 100;

unsigned int checkSums[SUM_ARR_SZ];

string fileNames[SUM_ARR_SZ];

This gives your program the flexibility to run checksums on several files (up to 100) and remember which sums go with which files.

Your program should then be able to verify that a specified file has not been compromised by running the checksum over it and verifying that the checksum is what it was previously.

Your program *must* read the file into a char array. Make the array size 100000 chars so that it is large enough for our file. After the file is stored in the array, your program must loop through the array to compute the checksum using the algorithm described above (simple sum).

Since this is essentially an operation on a binary file (even though text may be stored in the file), open the file in binary mode to prevent the system from performing any interpretation on the data like this:

inFile.open(filePath.c_str(), ios::binary);

Explanation / Answer

#include #include #include #include #include using namespace std; int main() { //declare variables string filePath; void savefile(); char choice; int i,a, b, sum; sum = 0; a = 0; b = 0; ifstream inFile; //arrays const int SUM_ARR_SZ = 100; string fileNames[SUM_ARR_SZ]; unsigned int checkSums[SUM_ARR_SZ]; do{ cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote