Implement your algorithm in python

Assignment Help Python Programming
Reference no: EM132309263

Assignment

Write a first program that loops, prompting the user to enter their last name, first name, meter number, previous reading and current reading, and then writes that data out to file called 'customers.txt'. The program should check inputs for validity according to the following rules:

First and last names must be alphabetic. No spaces or special characters. Names must be less than 20 characters long.
Meter number must be an eight-digit number between 26000000 and 79999999
Meter readings must be positive floating-point numbers with a six-digit integer part and a single-digit decimal part (e.g. 123456.7)
Current reading must be greater than or equal to the previous reading
The file should record each customers information on a single line and the output file should have the following appearance (last name appears first):

Luigi,Mario,26112233,123456.7,234567.8

Vader,Darth,37223344,567890.1,678901.2

A typical example of the display of your program can be as follows. Your program MUST follow the same display style.

------------------------------------------------

Superstar Energy Australia (SEA) Billing System

------------------------------------------------

Enter last name : Luigi

Enter first name : Mario

Enter meter number : 26112233

Enter previous reading: 123456.7

Enter current reading : 234567.8


------------------------------------------------

Do you want to enter another customer? (y/n): y

------------------------------------------------

Enter last name : Vader

Enter first name : Darth

Enter meter number : 37223344

Enter previous reading: 567890.1

Enter current reading : 678901.2


------------------------------------------------

Do you want to enter another customer? (y/n): n

------------------------------------------------

Goodbye.

In case of an invalid input, the display can be as follows.

...

Enter last name : L000

Invalid input! Last name must be an alphabetic string.


Enter last name : Luigi

Write a second program that opens the 'customers.txt' file for reading and then reads each record, splitting it into its component fields and checking each field for validity. The rules for validity are as in your first program, with the addition of a rule that specifies that each record must contain exactly five fields. Your program should print out each valid record it reads. Your program should terminate when it reads an invalid record, printing out on which line number the error occurred, and what the error was.

A typical example of the display of your program can be as follows. Your program MUST follow the same display style.

------------------------------------------------

Superstar Energy Australia (SEA) Billing System

------------------------------------------------

Customer Data - Record (1)

------------------------------------------------

Last name : Luigi

First name : Mario

Meter number : 26112233

Previous reading: 123456.7

Current reading : 234567.8


------------------------------------------------

Customer Data - Record (2)

------------------------------------------------

Last name : Vader

First name : Darth

Meter number : 37223344

Previous reading: 567890.1

Current reading : 678901.2


------------------------------------------------

End of Customer Data

------------------------------------------------


In case there is a record with an invalid data, for example

Luigi,Mario,26112233,123456.7,234567.8

Vader,Darth,17223344,567890.1,678901.2


The output can be as follows.

------------------------------------------------

Superstar Energy Australia (SEA) Billing System

------------------------------------------------

Customer Data - Record (1)

------------------------------------------------

Last name : Luigi

First name : Mario

Meter number : 26112233

Previous reading: 123456.7

Current reading : 234567.8


------------------------------------------------

Invalid record in line (2)!

------------------------------------------------

Meter number is outside the valid range.


You need to develop the system by completing the following three tasks:

Task 1

Draw flowchart/s that present the steps of the algorithm required to perform the tasks specified.

Task 2

Select at least six sets of test data that will demonstrate the 'normal' operation of your program; that is, test data that will demonstrate what happens when a VALID input is entered.

Note: for this program, valid normal input INCLUDES data that does NOT conform to the rules specified. This is because it is the function of your program to DETECT such erroneous data.

Select at least three sets of test data that will demonstrate the 'abnormal' operation of your program. For these programs, this might include the inability to write to the output file, or in the case of the second program the inability to open the file.

Set your test results out in a tabular form as follows: test data type, test data, the reason it was selected, the output expected due to using the test data, and finally the output actually observed when the test data is used. It is important that the output listings (i.e., screenshots) are not edited in any way.

Task 3

Implement your algorithm in Python. Comment on your code as necessary to explain it clearly.

In addition, for this exercise, use multiple functions, instead of using a single function to do everything. Create a good design of the functions to make the best use of the code and avoid duplication.

You also need to design your program so that it has components that can be reused in another program if needed. Handle exceptions appropriately and use appropriate data structures.

Run your program using the test data you have selected and complete the test data table.

Reference no: EM132309263

Questions Cloud

Develop a four-week problem-solving treatment : Develop a four-week Problem-Solving Treatment (PST) approach to help a student struggling with ADHD or weight loss management. Use the seven-step strategy below
How identifying market trends for products : Describe the process of how identifying market trends for products.
Protected resource without an authorisation : What are three consequences to your business if it uses another company's protected resource without an authorisation?
Right price and of good quality : If you were the manager, what measures would you put in place to ensure that the acquiring of resources is conducted in a timely manner
Implement your algorithm in python : Create a good design of the functions to make the best use of the code and avoid duplication - design your program so that it has components that can be reused
Explain the term consultation plan : Explain the term "consultation plan" and name 4 ways it can be conducted.
Develop a new product for the company export market : Jonathon, a product manager at Polymath Electronics, has been assigned to lead a team that will develop a new product for the company's export market.
Channels are managed through specialized intermediaries : The implementation of an indirect channel is advantageous as CRM activities can conveniently be controlled by the manufacturer.
Myth of the separation of roles between manufacturers : What was the traditionally accepted myth of the separation of roles between manufacturers and their dealerships?

Reviews

len2309263

5/21/2019 1:35:01 AM

Test Data Table Test data type Test data The reason it was selected The output expected due to the use of the test data The screenshot of the actual output when the test data are used

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

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