Lab05 write a program that reads a file containing A numbers and writes a sorted output to a file

$30.00 $24.00

Requirements In this lab, you are required to write a program that reads a file containing A numbers and writes a sorted output to a file. The number of lines in the file is not going to be more than 100 lines. The problem with the file is that students submit A numbers with all…

Rate this product

You’ll get a: zip file solution

 

Categorys:

Description

Rate this product

Requirements

In this lab, you are required to write a program that reads a file containing A numbers and writes a sorted output to a file. The number of lines in the file is not going to be more than 100 lines. The problem with the file is that students submit A numbers with all sorts of formats. Below are some examples of A numbers:

  • cat input.txt A1001.txt A00010001.txt A33333

34222

a3333.txt

Since students use different formatting instructions, it is extremely difficult to sort. Your job is to write an insertion sort that can sort this input file based on A numbers. According to BCIT and COMP2510, a proper A number format is the following:

A0XXXXXXXXX.txt

It starts with a capital A, followed by 0. Then, there are 7 numeric numbers followed by “.txt”. However, the input file contains A number formats that are not consistent with the above specification. Dropping A, lower case a, no .txt, not leading 0’s etc. Unfortunately, your program must still be able to sort it. A1001.txt is actually A00001001.txt, but the student didn’t bother to include leading 0’s. 34222 is A00342222.txt, but the student didn’t include A, leading 0’s and .txt. Your job is to sort this file in an ascending order even with such data not following the format.

  • cat output.txt A1001.txt

a3333.txt

A00010001.txt

A33333

34222

You must use a insertion sort to implement the sorting algorithm. The Below are additional specifications of this lab.

  1. The first argument is the intput file, and the second argument is the output file name. The run command will be

./<name of executable> <input file> <output file>

  1. There are no corner cases in this lab.

  1. The number of lines is guaranteed to be less than 100 lines, but each line is guaranteed to be maximum 100 characters.

Restrictions

  • Your output must have the same content format as the input, but just different orders

  • No trailing spaces or extra new line characters at the end of file as it will fail the diff

  • You must only use a insertion sort

  • Sample input and output files will be provided. Make sure to use diff to ensure that your output format matches with the expected output format.

Grading

I will provide sample input and output files. Make sure to test against those to ensure that your program output format works. Any grading failure due to not following specifications will result in 0. For full marks this week, you must:

  • (1 point) Correctly submit A number file

  • (1 point) Not having any files in github other than lab5.c and AXXXX.txt

  • (3 point) Generate a correct solution (including correct memory allocation and deallocation) to the problem(s) in this lab

Submission Files

  • You must deliver only one .c file named: lab5.c (do not capitalize)

  • AXXXX.txt (empty file, but with your A number as file name. Make sure to include 0’s, match this A number with your A number in learning hub, and have .txt extension)

  • Github: https://classroom.github.com/a/WPfW8sVZ

Lab05 write a program that reads a file containing A numbers and writes a sorted output to a file
$30.00 $24.00