Computers and Technology

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 generateoutput to the console (terminal) screen as specified below.
Command Line Parameters

1. Your program must compile and run from the command line.

2. The program executable must be named "checksum" (all lower case, no spaces or file extension).

3. Input the required file names as command line parameters. Your program may NOT prompt the user to enter the file names. The first parameter must be the size, in bits, of the checksum. The second parameter must be the name of the file used for calculating the checksum, as described below. The sample run command near the end of this document contains an example of how the parameters will be entered.

4. Your program should open the two files, echo the processed input to the screen, make the necessary calculations, and then

Checksum size

The checksum size is a single integer, passed as the first command line argument. The valid values are the size of the checksum which can be either 8, 16, or 32 bits. Therefore, if the first 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

The number X is not a valid checksum size: valid checksum sizes are 8, 16, or 32.

The message should be sent to STDERR. (Note that the number X shown above should be the invalid

Format of the input file

The input file will consist of the valid ASCII characters associated with the average text file. This includes punctuation numbers, special characters and whitespace.

Output Format

The program must output the following to the console (terminal) screen:

1. Echo the input file

2. Print the checksum. The echoed input text should be in rows of exactly 80 letters per row, except for the last row, which may possibly have fewer. These characters should correspond to the input text.

The checksum line should be formatted as follows Where X is the checksum size of 8, 16, or 32 and the filename xyz. ext is the input filename and Z is the calculated sum.

Your program must read in an input text file that may contain uppercase letters, lowercase letters and non-letter characters. Your program should then calculate the checksum appropriately for the size specified in the command line. Specifically, if the checksum is 8 bits long, each character should be used as the number to be added to the checksum. Likewise, if the checksum is 16 bits long, each two characters should be added to the checksum. Note that there is a 50% chance that there will be one character short on the input file. In that case use the character "X" (an uppercase X) as the pad character. Similarly, if the checksum is 32 bits, use the same technique and character to pad the input string appropriately.

Sample Run Command

C or C++ program:

Prompt$ ./checksum 8 inputText1.txt

Java program:

Prompt$ java checksum 8 inputText1.txt

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, dondre54
in 2007, floridians died in alcohol-related collisions.a.  501b.  1,051c.  5,015d.  10,839
Answers: 1
image
Computers and Technology, 22.06.2019 20:00, random286
How is the number 372 written when expanded out to place values in the base 8 (octal) number system? a. 2 x 4 + 3 x 2 + 4 x 1 b. 3 x 64 + 7 x 8 + 2 x 1 c. 3 x 8 + 7 x 7 + 2 x 6 d. 3 x 100 + 7 x 10 + 2 x 1
Answers: 1
image
Computers and Technology, 23.06.2019 02:50, bfell92
There’s only one game mode that stars with the letter ‘e’ in cs: go. which of the options below is it?
Answers: 1
image
Computers and Technology, 23.06.2019 06:30, Knownothing
When early motion pictures played in movie theaters, they were often accompanied by live organ or piano music. which of the following are the most likely reasons that this happened? (select all that apply). the music was provided to distract audience members from the loud sounds made when filmstrips were changed. the music accompanied the movies because the movies were silent and audiences were used to hearing music during plays in theaters. the music usually was played before, and sometimes after the movie, as an alternative form of entertainment. the music viewers to interpret the dramatic action in the films.
Answers: 2
Do you know the correct answer?
In this assignment you'll write a program that calculates the checksum for the text in a file. Your...

Questions in other subjects:

Konu
Mathematics, 10.05.2021 01:00
Konu
Mathematics, 10.05.2021 01:00
Konu
Computers and Technology, 10.05.2021 01:00