Write functions to perform the following tasks

Assignment Help PL-SQL Programming
Reference no: EM13309797

Task A

Download the files bank.txt and assignment2.py. The file bank.txt is the input file for the program. It consists of a number of lines of text, each with five fields. These fields are:
• The customer's first name
• The customer's last name
• The customer's account number
• The account type (savings, credit or cheque)
• The account balance

Assignment2.py already has some functionality added - ignore that for the moment.
For each of the following functions provide the expected inputs, outputs and pseudocode in your report (note: you will probably find the assignment easier if you do this BEFORE you do your coding)

a) Write a new function (called readInputFileIntoList) which will read the file bank.txt and place individual customer records into a list (effectively a ‘list of lists'). The function should NOT take the bank list as a parameter. It should return the bank list via its return statement.

You may not assume that you know how many records are in the input file - it must work for any number of lines.

For each line in the input file you should create an individual list with five elements (listed above). Use the ‘split' function to help you with this. Once you have created this list, add it to the bank list. The result of executing readInputFileInfoList should be a list of bank records - one for each line in the file.

b) Write a function called ‘printIndividualRecord'. It should take a list (corresponding to a single bank record) as a parameter. If the record is

Bruce Willis 123313 savings 405.00

the function should print out the details of the record in the following format

Bruce Willis has a savings account with account no: 123313
There is $405.00 in this account.

c) Write a function called ‘printAllRecords', which calls printIndividualRecord for each record in the bank list. It should take the bank list as a parameter.


Task B


Examine the functions already authored in assignment2.py.
• swap
• maxListByItem

In the code, write a high-level description of what each of these functions is intended to do as a comment above the function code. This description should be no longer than five lines. Marks will be awarded according to how well your response reflects your understanding.

 

Task C


Examine the function ‘sortListUsingSelectionSort' that has been written in assignment2.py. This function is not complete. Use the functions from task B to complete the implementation of this function. Note - it should not be necessary to move (change the order of) or delete the code that is already there. When complete the function should have sorted the list in descending order (biggest item first).

In the code (not the report) add a brief comment (1 or 2 lines maximum) to each line to explain how the line contributes to the implementation of the selection sort.

Also add a comment above the function to describe to someone else who might want to use it at a later time. This comment should be no longer than 5 lines.

Marks for the comments will be awarded according to how well they reflect your understanding of the code.

 

Task D

Write functions to perform the following tasks. Each function should be properly commented, use well-chosen identifier names and have appropriate parameters and any other good programming practices.

1) Write a function, called ‘sortAccountTypeLastName' that sorts the list by the account type. If account types are the same, sort the list by last name. You can use either insertion sort or bubble sort for this function. The original list should be passed in as a parameter. This list should be copied into a second list which should be sorted and returned by the function.

2) Write a function, called ‘printListToFile', that will write the details of a list to a file called ‘bank.out'. The format for the output file should be the same as the input file. In other words, it should be possible to use ‘bank.out' as input to the program.

3) Write a function, called ‘addInterest' that charges 10% interest to each account with a negative account balance. Other account balances should remain unchanged.

4) Write a function, called ‘binarySearch', implements a binary search. This function should take three parameters.

a. the target (the value that you are looking for)
b. the field being searched(eg account type, account balance etc.).
c. the list itself

If the target is found, return the index value where it was found. Otherwise the function should return -1.

5) Write a function, called ‘sortAnyTwoFields' which performs a similar task to ‘sortAccountTypeLastName' but which is more general. This function should have three parameters

a. field1 - the first field to be sorted on
b. field2 - the field to be sorted on if the values of field1 are equal
c. bList - the bank list

The original list should be passed in as a parameter. This list should be copied into a second list which should be sorted and returned by the function. For example

sortAnyTwoFields (CUSTOMER_LAST_NAME, CUSTOMER_ACCOUNT_BALANCE, bankList)

will sort by the customer's last name. If the last names are the same, then the list is sorted by account balance.

Reference no: EM13309797

Questions Cloud

How long will it take alexis to pay off the loan : how long (how many monthly payments) will it take Alexis to pay off the loan and accrued interest completely (to a zero balance). Use linear interpolation as necessary to get as close an answer as possible.
Define the initial rates at various substrate concentrations : The initial rates at various substrate concentrations for an enzyme-catalyzed reaction are as follows. [S]/M.............Vo/10^-6 M/min 2.5x10^-5.......38.0 4x10^-5.........53.4 6x10^-5.........68.6 8x10^-5.........80.0 16x10^-5.......106.8 20x10^..
What amount must jackie invest over the next 15 years : Jackie is now exactly 40 years old, and plans to invest a recurring amount over the next 15 years (until age 55) in an account bearing 10% annual interest. She plans to retire at age 65 and live to age 100 (don't we all).
Determine the gram molecular weight of the air : given a 22.414 liter volume of air at STP containg: 21.224kPa oxygen, 79.119 kPa nitrrogen, 0.946kPa argon,and 0.036 k carbondioxide. Find the gram molecular weight of the air.
Write functions to perform the following tasks : Write a function, called ‘binarySearch', implements a binary search. This function should take three parameters.
Determine the value of the equilibrium constant : Find the value of the equilibrium constant at each temperature you must first find the value of G0 at each temperature by using the equation G0 = H0 - TS0 For this reaction the values are H0 = +88.3 kJ/mol and S0= 151.3 J/mol*K
Determine the pressure at stagnation point on the nose : determine the pressure at stagnation point on the nose of the airplane. also determine the manometer reading h for the manometer attached to the static pressure tap within the test section of the wind tunnel if the air velocity
Determine a soil with a hydraulic conductivity and depth : Is a soil with a hydraulic conductivity of 1*10-5 cm/s and depth of 10 ft equivalent to a soil with hydraulic conductivity of 1*10-6 cm/s and depth of 5 ft
What is the angle of their final velocity vector : A sticky hockey puck slides along a frictionless horizontal ice surface at 75m/s in the + x-direction. what is the angle of their final velocity vector below the +x direction

Reviews

Write a Review

PL-SQL Programming Questions & Answers

  Indicate the changes

Indicate the changes (using the shorthand representation) that you would need to make to the original Premiere Products database design to support the following requirements. There is no relationship between customers and sales reps.  When a custo..

  Write a compete pl/sql program to display the staffno

Write a compete PL/SQL program to display the StaffNo,

  Write an update statement that modifies the row

Write an UPDATE statement that modifies the row you just added to the Categories table. This statement should change the ProductName column to "Woodwinds", and it should use the CategoryID column to identify the row.

  Write a select statement

Write a SELECT statement that returns these columns from the CustomerAddresses view that you created in exercise 1: CustomerID, LastName, FirstName, BillLine1.

  Trigger named products_update

Create a trigger named Products_UPDATE. This trigger should insert the old data about the product into the ProductsAudit table after the row is updated. Then, test this trigger with an appropriate UPDATE statement.

  Decomposition for r = (a,b,c,d,e )

Give a good decomposition for R = (A,B,C,D,E ) with the following functional dependencies:

  The cast function to return the date added column

A column that uses the CAST function to return the DateAdded column with its full time only (hour, minutes, seconds, and milliseconds)

  Write pl-sql procedures and functions

Write PL/SQL procedures and functions to populate and query that database

  Create program to enter first and second number

Create a program that enters first and a second number. The first and second number that will be entered should be computed in halves, quarter, double, and square.

  Script that creates and calls a function named

Write a script that creates and calls a function named fnDiscountPrice that calculates the discount price of an item in the OrderItems table (discount amount subtracted from item price). To do that, this function should accept one parameter for th..

  Trigger named products_insert

Create a trigger named Products_INSERT that inserts the current date for the DateAdded column of the Products table if the value for that column is null. Test this trigger with an appropriate INSERT statement.

  Determine resonant frequency in series rlc resonant circuit

Given the series RLC resonant circuit in the figure, operating at variable frequency, determine: The resonant frequency ω o ,  The circuit’s quality factor Q , The cut-off frequencies, f 1  & f 2  and the bandwidth BW

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