Question: Please write in Python 3 Given an input file, with a user-entered filename (e.g., Books.txt), where each line includes an ISBN, unit cost and the

Please write in Python 3

Given an input file, with a user-entered filename (e.g., Books.txt), where each line includes an ISBN, unit cost and the number of copies of a book to be ordered, write a Python program to compute and print each book's ISBN, unit cost, number of copies to be ordered and the total cost of the book order. Also, at the end of the information about each book ordered, your program should compute and output the total cost of all books ordered.

In addition, besides printing the required output, your program must also write the ISBN, number of copies ordered and the total cost of the book order to a new file called YourOrders.txt.

Include exception handling in your program so that an error is produced and your program exits cleanly if the input file is not available.

Call your program file BookOrders.py and test your program with the given file, Books.txt, as shown below. Test your program and submit your files including your input file and the file YourOrders.txt created by your program.

Note: The input file should be placed in the same directory as the .py file for testing (or the pathname to the input file would need to be specified).

For example, with the given input file Books.txt as follows:

9780374386139,19.49,5 9781451673265,21.29,8 9780007350773,15.99,2 9780544003415,35.99,3 9780066238500,30.90,6 9780545162074,52.65,8 9780375386130,29.49,10 9781001673293,41.29,8 9780117350799,18.99,4 9781654003415,18.99,6 9782667238543,20.90,5 9781431620722,32.99,2 

The output from the program should be:

Enter filename: Books.txt ISBN Cost Copies Total Cost 9780374386139 $19.49 5 $97.45 9781451673265 $21.29 8 $170.32 9780007350773 $15.99 2 $31.98 9780544003415 $35.99 3 $107.97 9780066238500 $30.90 6 $185.40 9780545162074 $52.65 8 $421.20 9780375386130 $29.49 10 $294.90 9781001673293 $41.29 8 $330.32 9780117350799 $18.99 4 $75.96 9781654003415 $18.99 6 $113.94 9782667238543 $20.90 5 $104.50 9781431620722 $32.99 2 $65.98 The total of all orders is: $1999.92 

And the contents of the output file, YourOrders.txt, should be:

9780374386139,5,97.44999999999999 9781451673265,8,170.32 9780007350773,2,31.98 9780544003415,3,107.97 9780066238500,6,185.39999999999998 9780545162074,8,421.2 9780375386130,10,294.9 9781001673293,8,330.32 9780117350799,4,75.96 9781654003415,6,113.94 9782667238543,5,104.5 9781431620722,2,65.98 

If the program tries to open a file that does not exist (e.g., Book.txt), then the following input prompt, input and output should be generated:

Enter filename: Book.txt Error: File not found.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!