Write a cpp program to read records in a plain text file

Assignment Help C/C++ Programming
Reference no: EM131826916

Programming and Data Structures Asignment: Remove Duplicated Records

1 Introduction

You will write a C++ program to read records in a plain text file, then remove duplicated records, and write unique ones to a plain text file. You can use any algorithm and data structures that you prefer, as long as the results are correct. It is preferred, but not necessary, that your algorithm is as efficient as possible, both in processing time as well as memory management.

2 Input and Output Specification

The input is one text file with 0 - 10000 records. The content of each record is confined to a pair of {} and doesn't contain '{' or '}', but may have other symbols like space, comma, colon, single or double quote, and so on. In the input and output file, each line ends in a '\n' character. One record may not be necessary in one line in the input file. But you should output each unique record in one line without any spaces. The output records can be in any orders. It doesn't matter if you have or don't have one empty line at the end of the output file.
Example of input files (between the lines)

input1.txt
{id:1234567,first:Mary,last:Green} {id:1234568, first:Peter, last:Morgan} {id:1234567, first:Mary, last:Green}
input2.txt
{id:1234567,
first:Mary,last:Green,GPA:4.0} {id:1234568, first:Peter,
last:White , GPA:3.8}
{id:1234567, first:Mary, last:Green, GPA:3.9}
output1.txt
{id:1234567,first:Mary,last:Green} {id:1234568,first:Peter,last:Morgan}
output2.txt

{id:1234567,first:Mary,last:Green,GPA:4.0} {id:1234568,first:Peter,last:White,GPA:3.8} {id:1234567,first:Mary,last:Green,GPA:3.9}

3 Program specification

The main program should be called "removeduplicated". Call syntax is as follows (from the OS prompt):

./removeduplicated input=input1.txt output=output1.txt

Notice that the file name will not necessarily be the same every time. Therefore, your program will have to take that into account.

4 Requirements

• Homework is individual. Your homework will be automatically screened for code plagiarism against code from the other students and code from external sources. If you copy/download source code from the Internet or a book it is better you acknowledge it in your comments, instead of the TAs detecting it. Code that is detected to be copied from another student (for instance, renaming variables, changing for and while loops, changing indentation, etc) will result in "Fail" in the course and being reported to UH upper administration.

• You can develop your program on any C++ compiler (MS Visual C++, Borland C++, Intel C++), BUT you must test your program in GNU C++. The TAs have no obligation to test your program on any compiler other than GNU C++.

• don't forget to comment your code, especially complicated code. You must include a short summary of your main functions in the main cpp file.

• In input files, lines might begin with spaces, there might be empty lines, lines with only spaces, and so on. Your program need to robustly deal with these cases. Your program should not crash, halt unexpectedly or produce unhandled exceptions.

• A program that can be compiled count 10 points. Your program will be tested with 9 test cases (each counts 10 points), going from easy to difficult.

• Correctness is more important than speed. You should always err on the side of caution submitting a slow program that works correctly than a fast one that fails in many cases.

Attachment:- Input-Output-Files.rar

Reference no: EM131826916

Questions Cloud

What was the consolidated balance for land : What was the consolidated balance for Land in a consolidated balance sheet prepared at the date of the acquisition combination
Which group does walmart have monopoly power over : Some people think that businesses create monopolies by destroying their competition, and there is certainly some truth to that.
Prepare schedule to show equity income : Prepare a schedule to show the equity income Tinker should recognize for 2011 related to this investment
Determining the distribution functions : Show that X and Y are dependentb. Show that X^2 and Y^2 are independent. Hint, this might be easier by using distribution functions, rather than density functio
Write a cpp program to read records in a plain text file : You will write a C++ program to read records in a plain text file, then remove duplicated records, and write unique ones to a plain text file.
Problem on stage performance of shakespeare hamlet : Isn't it surprising that movies, with tickets that cost around $10, often use vastly more economic resources than stage plays where tickets can easily cost.
Prepare the general journal entries required to account : Prepare the general journal entries required to account for the previous information and transactions assuming the government uses the purchases method
Outcome of the second roll : A 4-sided fair die is rolled twice. What is the probability that the outcome of the first roll is greater than the outcome of the second roll?
Define a sample space for the experiment : A coin is tossed until the first head appears, and then the experiment is stopped. Define a sample space for the experiment.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Two dimensional int array to hold the prices of the seats

The Theater class shows a theater with an auditorium containing a fixed number of seats arranged in rows with each seat selling for a exacting price. The instance variables for the theater are:

  Write a c program that takes an integer argument

Write a C program that takes an integer argument from the command line and outputs the sum of all digits of the integer. For example, the result of the invocation sum of digits 12345 should be 15.

  What situations would a programmer use a void function

Describe what a void function is, and explain how it differs from other functions. In what situations would a programmer use a void function

  Create a ruby script that defines a function

Create a Ruby script that defines a function occurrences(list,key) that takes an array list and object key and returns the number of elements in list that are equal to key - Create a Ruby script that defines a function numSmaller(list,item) that t..

  Write a program that reads an unspecified number of numbers

Write and run a program that reads an unspecified number of numbers and then prints them together with their deviations from their mean.

  State whether the following are valid switch statements

State whether the following are valid switch statements. If not, explain why. Assume that n and digit are int variables.

  Create an array function - generate random numbers

Generate random numbers, report total number created, how many were 15, 16, or 17 and report this information to the user.

  Write a program that plays a tic-tac-toe game.

Using functional decomposition, write a program that plays a tic-tac-toe game.

  Function that returns the height of a binary tree

Write a function called getHeight() that returns the height of a given binary tree - CptS 122 Write a function called countSmallerThan() that returns the number of nodes whose values are smaller than the supplied input paramter

  What output would be produced by the program segment

What output would be produced by the following program segment?

  Uml diagram of all the classes

Speaking of converting into the correct object-type, the goal of the factory is to abstract away object creation.

  Write the code to test the queue class

Write the code to test the queue class by determining if the following strings are char-by-char palindromes:

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd