SWE 321 Object Oriented Programming – Lab

SWE 321 Object Oriented Programming – Lab

Write a Python program with the following 10 functions. Solution to the first program given as a sample.
o All input values are to be taken from the user.
o Ensure to check for possible error cases like mismatch of data type and input out of range, for every function.
o Include test cases for the functions with different parameters to ensure all working conditions.
1. greatestOfFour (w, x, y, z) – Function to find the greatest of four numbers w, x, y, and z, and return it. (Answer to this is given as an example)

1. Write a Python program that reads a text file called “sample.txt”. A sample of the file is provided below, you may add more details to the file. Your program must read the data from the file and count the number of words in the file

2. Write a Python program that reads a text file called bill.txt. The text file contains, item-IDs and item-prices. Your program should read each item and respective prices from the file; find the most expensive, least expensive item, count the number of items and give the total of all the prices. The program should output the report into a file called output.txt. A sample of source file and report file is given below.
bill.txt:
Item Price
A01 50.00
B31 149.50
A41 179.00
F01 169.50
C45 185.75
H21 29.25
output.txt:
*******************************************
BILL REPORT
*******************************************
There are total of 6 items purchased.
The most expensive item is “C45” with price 185.75

The least expensive item is “H21” with price 29.25
The total is 763.00
******************************************

SAMPLE ASSIGNMENT
Powered by WordPress