UCF - CECS Programming Assignment 2 8, 16, & 32 bit checksums October 30, 2021 1 Checksum In this assignment you’ll write a program that calculates the checksum for the text in a file. Your program...

1 answer below »
.


UCF - CECS Programming Assignment 2 8, 16, & 32 bit checksums October 30, 2021 1 Checksum In this assignment you’ll write a program that calculates the checksum for the text in a file. Your program will take two command line parameters. The first parameter will be the name of the input file for calculating the checksum. The second parameter will be for the size of the checksum (8, 16, or 32 bits). The program must generate output to the console (terminal) screen as specified below. 1.1 Command line parameters 1. Your program must compile and run from the command line. 2. Input the required file name and the checksum size as command line parameters. Your program may NOT prompt the user to enter the file names. The first parameter must be the name of the file used for calculating the checksum, as described below. The second parameter must be the size, in bits, of the checksum. The sample run command near the end of this document contains an example of how the parameters will be entered. 3. Your program should open the input text files, echo the processed input to the screen, make the necessary calculations, and then output the checksum to the console (terminal) screen in the format described below. CIS3360-McAlpin PA 2 1 Note All of the test data files contain a termination character LF represented as a hexadecimal ’0A’. This character is included in all the checksum calculations. 1.2 Checksum size The checksum size is a single integer, passed as the second command line argument. The valid values are the size of the checksum, which can be either 8, 16, or 32 bits. Therefore, if the second parameter is not one of the valid values, the program should advise the user that the value is incorrect with a message formatted as shown below: fprintf(stderr, "Valid checksum sizes are 8, 16, or 32\n"); The message should be sent to STDERR1. 1.2.1 Format of the input file The input file specified as the first command line argument, will consist of the valid 8 bit ASCII characters normally associated with the average text file. This includes punctuation, numbers, special characters, and whitespace. 1.2.2 Output Format The program must output the following to the console (terminal) screen, also known as STDOUT: 1. Echo the text from the input file. 2. The echoed input text should be in rows of exactly 80 characters per row, except for the last row, which may possibly have fewer. These characters should correspond to the input text. 3. Print the checksum. • Remember to pad with X if the input data does not align with checksum size for the checksum calculation. For example, if calculating a 16 bit checksum, it could be necessary to add an additional X to arrive at an input file size of an even 16 bit size input. Likewise for 32 bits. However, note that it may be necessary to pad with 1, 2, or 3 X characters for an even 32 bit size input. 4. The checksum line should be formatted as follows2 : 1Printing to STDERR can be accomplished using the followinge code:fprintf(stderr,normal printf format specifications ); Java uses System.err.println(...); 2Where the variable checkSumSize is the checksum size of 8, 16, or 32, the variable checksum is the calculated checksum. Note that the checksums are masked to print the appropriate sizes such as two hex characters for 8 bits, 4 hex characters for the 16 bit checksum, and 8 hex characters for 32 bit checksum. The variable characterCnt is the character count of the input file and includes the terminating charact LF or the hexadecimal value 0A. CIS3360-McAlpin PA 2 2 printf("%2d bit checksum is %8lx for all %4d chars\n", checkSumSize, checksum, characterCnt); 1.3 Submission instructions You must submit this assignment in Webcourses as a source file upload. Note that all submissions will be via Webcourses. The submitted programs will be tested and graded on Eustis. 1.3.1 Code Requirements • Header - the following Header Usage instructions/comments comment block should be at the beginning of the source file. /*============================================================================= | Assignment: pa02 - Calculating an 8, 16, or 32 bit | checksum on an ASCII input file | | Author: Your name here | Language: c, c++, Java | | To Compile: javac pa02.java | gcc -o pa02 pa02.c | g++ -o pa02 pa02.cpp | | To Execute: java -> java pa02 inputFile.txt 8 | or c++ -> ./pa02 inputFile.txt 8 | or c -> ./pa02 inputFile.txt 8 | where inputFile.txt is an ASCII input file | and the number 8 could also be 16 or 32 | which are the valid checksum sizes, all | other values are rejected with an error message | and program termination | | Note: All input files are simple 8 bit ASCII input | | Class: CIS3360 - Security in Computing - Fall 2021 | Instructor: McAlpin | Due Date: per assignment | +=============================================================================*/ CIS3360-McAlpin PA 2 3 • The following Academic Integrity Statement comment block should be at the end of the source file. /*============================================================================= | I [your name] ([your NID]) affirm that this program is | entirely my own work and that I have neither developed my code together with | any another person, nor copied any code from any other person, nor permitted | my code to be copied or otherwise used by any other person, nor have I | copied, modified, or otherwise used programs created by others. I acknowledge | that any violation of the above terms will be treated as academic dishonesty. +=============================================================================*/ 1.4 Program Notes and Hints One possible breakdown to solve this problem is as follows: 1. Collect the command line input arguments and print them to the console. Remember to remove or comment out this test code when running the testing scripts. 2. Read the file and print it out to the console. 3. Adjust the output to print 80 characters per line. 4. Calculate the 8 bit checksum. Remember that the checksum is a running total with no overflow. 5. Resolve the calculations and padding for both 16 and 32 bit checksums. CIS3360-McAlpin PA 2 4 1.5 Grading Scoring will be based on the following rubric: Table 1.1: Grading Rubric Deduction Description -100 Cannot compile on eustis -100 Your program does not successfully compile from the command line with one of these commands: C program: prompt$gcc -o pa02 pa02.c C++ program: prompt$g++ -o pa02 pa02.cpp Java program: prompt$javac pa02.java Note: If you are submitting a Java program, the class file must be named “pa02.java” and the class name must be “pa02”. -100 Cannot read input parameters specified on command line -100 Cannot write output to stdout - 90 The program does not run from the command line without error or produces no output. - 70 The program compiles, runs, and outputs the input file, but crashes thereafter or produces no checksum output. - 20 Fails to produce valid 8 bit checksum - 20 Fails to produce valid 16 bit checksum - 20 Fails to produce valid 32 bit checksum - 25 Does not have Header Usage instructions/comments statement - 25 Does not have Academic Integrity statement Start with 100 points and deduct per the schedule above CIS3360-McAlpin PA 2 5 1.6 Testing 1.6.1 Baseline There are 5 baseline files included in the ZIP file. (Additional test files are described in the next section.) The filename and their corresponding checksums are shown in the table below: Table 1.2: Baseline Test Schema Filename 8 bit checksum 16 bit checksum Pad 32 bit checksum Pad Input (hex) i1.txt 6b 610a - 610a5858 XX 610a i2.txt cc 6bb9 X 61610a58 X 61610a i3.txt 2d c26b - 6161610a - 6161610a i4.txt 8e cd1a X 6bb9b9b9 XXX 616161610a i5.txt ef 23cc - c26bb9b9 XX 61616161610a Results were obtained using the command: bash basetest.sh pa02.|c|cpp|java| 1.6.2 Advanced Testing There are eight input test files of significantly more varied content than used in the Baseline Test Schema shown above. 1. Every input file has a single line of text terminated by the hexadecimal character ’0A’ or the NEWLINE character. 2. Some input files are less than 80 characters long, others aren’t. 3. More testing files are supplied than are used in the pa02Test.sh script. 4. After uploading the testing shell script (and corresponding files) remember to execute the command chmod +x *.sh to grant execution privileges for the script. 5. The script is executed at the command line by the command bash pa02Test.sh pa02.c where the checksum program filename has the correct extension for your submission. Valid extensions are .c for C, .cpp for C++, and .java for Java. CIS3360-McAlpin PA 2 6
Answered 3 days AfterNov 16, 2021

Answer To: UCF - CECS Programming Assignment 2 8, 16, & 32 bit checksums October 30, 2021 1 Checksum In this...

Swapnil answered on Nov 20 2021
122 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here