Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that will search a text file of strings representing numbers of type int and will write the following to the screen: a

Write a program that will search a text file of strings representing numbers of type int and will write the following to the screen:

  • a count of integers in the file
  • largest integer in the file
  • smallest integer in the file
  • average of the integers in the file
  • sum of all integers in the file

Include appropriate error handling in case a line contains more than one int or it contains a String. Wrap all the work you are doing with the file in a try/catch/finally block with appropriate "catch" sections; the finally block will be where you close your file object (if desired, look this up online for more information regarding "finally" and when it is executed, specifically that it is executed in case of success or failure of the entire try block).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Python program that reads a text file containing integers performs calculations and handles potentia... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Primer Plus

Authors: Stephen Prata

6th Edition

978-0321776402, 0321776402

More Books

Students also viewed these Programming questions