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

  Develop logic to accept number of passengers-zones as input

Develop the logic for a program that accepts the number of passengers and zones crossed as input. the output is the ticket charge.

  Create the logic for a program that accepts input values

Create the logic for a program that accepts input values for the projected cost of a vacation and the number of month until vacation. Pass both values to a method that displays the amount you must save per month to achieve your goal.

  Write program to accept a list of student-s name

Write a program that will accepts a list of student's name, individual scores for quiz1, quiz2 and quiz3. Your program should then compute for the average of 3 quizzes.

  Design and write payroll program-employee-s hourly pay rate

Design and write a payroll program that will prompt the user to enter an employee's hourly pay rate and the number of hours worked.

  Examples of predefined control events

How are these examples of predefined control events and its usage in programming? Delegate Object that contains a reference to a method Encapsulates a method provides a way for a program to take alternative

  Short memo to the vice-president of production

Write a short memo to the vice-president of production recommending whether the availability of any of the three resources (blending, purification, or labor) should be increased from current levels. If you recommend an increase, specify at most ho..

  Write program which permits user to enter first name

Write the program which permits the user to enter first names of candidates in university election and number of votes received by each candidate.

  Write multiplication program make positive one-digit integer

Write down program which will aid the elementary school learn multiplication. Use Random object to make two positive one-digit integers.

  Create the behavioral vhdl model for thirty two-bit alu

Create the behavioral VHDL model for 32-bit ALU. The ALU has 4-bit "op" control singal. Relationship between the "op" and operations of ALU.

  Design the swing applet and html test file

You can download sound clips and graphics images from Internet to use in the program. Design the Swing applet named JPartyPlanner and HTML test file to run Swing applet.

  Amend the constructor so that it has an additional parameter

Define an accessor getYears(), which returns the number of years in teaching. Declare a field to store the member's id number. Amend the constructor so that it has an additional parameter of an appropriate type which it then uses to initialise the id..

  Write method to display the number by adding hundred

displayItTimesTwo(), and displayItPlusOneHundred(). Write each method to perform the task its name implies. Save the application as TestMethods.java.

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