BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写 | COMPSCI 210 Assignment 2

C语言代写 | COMPSCI 210 Assignment 2

本次新西兰代写主要为C语言编程的assignment

Assignment goal

This assignment will require you to implement 2 simple C programs. The first program reads
a text file, counting the frequency of the alphabetical letters it contains. The program then
writes a bar graph illustrating the non-zero letter frequencies to a text file. A skeleton file

The second program is a simple Battleship game. Player 1 chooses the position of two 2-cell
ship (2×1 or 1×2) in a 4×4 grid. Player 2 repeatedly chooses coordinates to fire at, until all ships
are sunk.

We have provided you with skeleton files called A2_1.c and A2_2.c which you will use to
implement these 2 programs. You can see that we have included the stdio.h , stdlib.h,
and string.h header files, as well as the stdlib.h header file for program 2. Do NOT
include any other header files. Several functions which you will need to define to implement

these programs have also been declared. Do NOT declare or define any other functions. You
may define and use macros if you wish.

Program 1 (30 marks)

Part 1 (5 marks)

When the A2_1 program is run, apart from the name of the program, the program should
take two command line arguments:
1. The name of the input text file the program will read and use to generate a count of
letter frequencies.
2. The name of the output text file the program will write to with the bar graph
illustrating the non-zero letter frequencies.

For example, if the name of the input file is “test1.txt” and the name of the output file is
“output1.txt”, the command below is used to run the program (“$” is the command window
prompt):

$ ./A2_1 test1.txt output1.txt

In this part of the program you will need to make sure that the program is passed two
command line arguments. If not, the following message should be displayed:

Usage: ./A2_1 input_filename output_filename

This must be handled in the main() function of the program.

Part 2 (12 marks)

In this part of the assignment you will need to define the count_letter_frequency()
function for the A2_1 program. This function takes two parameters:
1. A pointer to a character array storing the name of the input text file.
2. A pointer to an integer array storing the letter frequencies.

The count_letter_frequency() function is called in the main() function. It reads
the text file specified by the first parameter and updates the character frequencies stored in
the integer array specified by the second parameter. Case is ignored, so the lowercase and
uppercase versions of a letter both increment the same frequency. For example, the text “Aa”
would have a frequency of 2 for the letter “a”.

Part 3 (13 marks)

In this part of the assignment you will need to define the draw_frequency_barchart()
function for the A2_1 program. This function takes two parameters:
1. A pointer to a character array storing the name of the output text file.
2. A pointer to an integer array storing the letter frequencies.

bestdaixie

评论已关闭。