Write program which reads a data file containing information

Assignment Help Programming Languages
Reference no: EM131290704

Script Programming/Python:

Transaction Report

In this assignment you will write a program which reads a data file containing information in different formats, validates this data, and prints out a report incorporating this data. The data file contains information about a set of credit card transactions which includes the name of the purchaser, the date of the transaction, the amount of the transaction, and the credit card number. The four values for each transaction will be on a single line separated by colons. Each of these pieces of information might be entered using different possible formats, and you should be able to recognize each. Each of the possible formats are:

• Name - a first name consisting of letters, followed by a space, optionally followed by a middle initial (one letter) that may have a period after it, followed by a space, followed by a last name consisting of letters, optionally followed by a space and one of Sr, Jr, III or IV, with a period possibly after the Sr or Jr.

• Date - (1) the date can be in a text form which is made up of the name of the month, followed by a space and then the day in the month (1 or 2 digits), followed by a comma and a space, followed by the year (4 digits); (2) the date can also be in a numerical form which is made up of the month as a number between one and twelve (1 or 2 digits), followed by a / or -, followed by the day (1 or 2 digits), followed by a / or -, followed by the year (2 or 4 digits - if 2 assume the missing two digits are 20 if the existing digits are 16 or less, and 19 otherwise).

• Amount - the monetary amount is given in the format of an optional leading dollar sign, followed by the dollar amount in digits, optionally followed by a period and 2 digits representing the cents.

• Credit card number - Three types of credit cards may be used: Visa, Master Card and American Express. Each of these has a particular format: Visa numbers are 16 digits long and may be a string of 16 digits without spaces or dashes, or they can be four groups of 4 digits with a space or dash between each group, and the number begins with the digit 4; Master Card numbers have the same formatting for 16 digits, but the number begins either with a value between 51 and 55, or between 2221 and 2720; American Express numbers are 15 digits long and may be a string of 15 digits without spaces or dashes, or they can be three groups of 4, 6 and 5 digits with a space or dash between each group, and the number begins with the value 34 or 37.

Your program should take the name of a data file as a command line argument. After validating it, the data file should be read line by line. Each line should have the contents of the transaction validated and extracted using regular expressions as much as possible. If a data line contains a value that is not properly formatted, an appropriate error message should be displayed about what is wrong and the data for that line should be ignored.

All data that is valid should be organized into a report in the following way: the transactions should be ordered such that those that use American Express cards come first, followed by those that use Master Card, followed by Visa. Within each credit card group, the transactions should be ordered chronologically based on the dates, with those that occur on the same date being ordered alphabetically by the person's last name, and if there are multiple transactions for the same person on that date, they should be ordered by the amount of the transaction.

As the data for a transaction is printed out in this report it should be in a standard format, not in whatever format was entered in the file. This format is:

• Credit Card numbers are listed as separate groups of digits with spaces between them.

• Dates are listed in the format MM/DD/YYYY, where MM is a two digit form of the month, DD is a two digit form of the day, and YYYY is a four digit form of the year.

• The name is printed as the last name followed by the optional Sr., Jr., III or IV and then a comma, followed by the first name and then the optional middle initial with a period after it.

• The amount is listed as a dollar sign, followed by the dollars, and followed by a period and two digits for the cents.

You should submit your commented source code, along with the data file you used to test your program, and the corresponding report made by your program for this file.

Reference no: EM131290704

Questions Cloud

Explain how the transaction can be fairly priced : Explain from an American's perspective how this transaction is like a series of forward contracts on the pound. Also, explain how the transaction can be fairly priced, which you can assume it is, even though the implied forward rate is the same fo..
How the group is set up and funded : Explain why the community needs your organization, then address the following:The specific mission of the group.The kinds of activities your organization will do to further its mission.How the group should be set up and funded.
Give two ways in which archaeologists identify a prehistoric : Give two ways in which archaeologists identify a pre-historic site.  Identify one natural factor that caused the Abagusii to migrate from Mount Elgon region to their present homeland. State the main factor that contributed to the growth of city-state..
Talk about leadership the topic : Class, when we talk about leadership the topic of what makes a good leader is always discussed. Indeed, multiple research and theories have tried to identify what makes a good leader.
Write program which reads a data file containing information : In this assignment you will write a program which reads a data file containing information in different formats, validates this data, and prints out a report incorporating this data.
Compare at least three print technologies : Compare at least three print technologies. Criteria to address includes, but is not limited to: Different maintenance needs and How to maintain the printers?
Explain what mitchell duneier and harvey molotch found : Explain the concepts of status, roles, social hierarchies, norms, rules and institionalization and path dependency? Of what meaning are these concepts to our lives.Do social structures challenge the notion of free will? Explain and substantiate y..
Calculate the next payment each party makes : The payments are made semiannually based on the exact day count and 360 days in a year. The current period has 181 days. Calculate the next payment each party makes.
Why are people still buying the given tape drives : Use the Web to find the state-of-the-art in tape system capacity and speed. Why are people still buying these tape drives? Will solid-state drives and Cloud storage change this?

Reviews

Write a Review

Programming Languages Questions & Answers

  Front end applications

How does a compiled binary executable store on the client computer?

  Using datagrid in an application

Update the field named fldQuestionDescription.

  Create a base class that contains all of the properties

Create a base class (also called a superclass) that contains all of the properties that are common to both of these products. Create 2 derived classes (also called subclasses) that contain different kinds of sizes.

  Write a program to enter series of numbers

Write a program that ask the user to enter a series of numbers ending with -1. After the -1 is input, program should print how many numbers are even and how many numbers are odd.

  This program is a simple shopping list

This program is a simple shopping list that could also be used for TODOs or similar purposes. The program maintains a list of items in a file, and each item has:

  Write a javascript function to validate a text-field

Write a JavaScript function to validate a text-field on a form that is to hold an email address. Now when writing this JavaScript function bear in mind that you won't be able to fully validate it unless you manage to interrogate the server in whic..

  Develop a company logo application

Copying the template to your working directory. Copy the directory C: Exampl esTutori al 26Exerci sesCompanyLogo to your C: Si mpl yVB2008 directory.

  Program to store highest value using two-dimensional array

Write down a program which uses the two-dimensional array to store highest and lowest temperatures for each month of the year.

  Issues into account for collecting user data via forms

In addition to making our forms easy to use we need to consider user privacy and the use of data. What are some of the issues which you believe you require to take into account for collecting user data via forms?

  Write a program called oscar office

Write a program called Oscar Office that instantiates at four different ticket agents. The Oscar Office program should prompt the user for the ticket agent they wish to purchase a ticket.

  Program to create an exit button.

Create a Clear button to clear the result text box and reset both NumericUpdown controls.

  How to assess quality of computer program

These are generally done at macroscopic level, but how would you assess quality of computer program if you received the e-mail with source listing of a program?

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