Sale!

CPSC 3400 Assignment #3

$30.00 $18.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (8 votes)

P5 exercises your understanding of code reuse and Python exceptions.
Submitted programs must:
1) provide the requested functionality
2) be appropriately documented (thorough but concise)
3) use Python constructs as intended (do NOT write a C-style program)
• re
• exceptions: https://docs.python.org/3/library/exceptions.html
4) be relatively robust

ALL ASSUMPTIONS SHOULD BE REASONABLE AND CLEARLY STATED
DO NOT HARD CODE

Rewrite your P3 Python program. Note that the specifications have been altered:
1) examine the contents of a text file (name specified on CL)
a. program to accommodate file errors
2) identify all valid prices that appear in the file
A valid price may be represented in the following forms
$x, where x is a string of one or more digits
with the restriction that the 1st digit is NOT zero
$x.bc, where x is string of one or more digits,
where 1st digit can be zero ONLY if x is a single character
b & c are single digits
in either case, if x is longer than 3 digits,
commas are used to separate subsequences of 3 digits
Invalid formats include
$y, where y is a string of one or more digits but the 1st digit is zero
$x.b, where b is a string of 1 or (3 or more) digits
$y.b, where y is as described above, and
b is a string of 1 or (3 or more) digits
3) “Normalize” all prices by dividing by the first number in the file
a. program to accommodate numeric and type errors
4) Store all prices into different sequences, based on values specified in #5
a. program to accommodate index and type errors
5) Output the different sequences into files as specified below
a) bucks.txt: all prices of whole numbers only
b) sale.txt, all prices with 99 cents
c) misc.txt all other valid prices

Each submitted program will be tested on the same input file
TEST YOUR PROGRAM BEFORE SUBMISSION

Name your Python file: P5.py AND upload to Canvas