Question: Given an arbitrary file Values.txt, create a program that calculates the average of the prime values in the file. Process: Read Lines from Values.txt Determine

Given an arbitrary file "Values.txt", create a program that calculates the average of the prime values in the file.

Process:

  1. Read Lines from "Values.txt"
  2. Determine if the line is an integer
  3. Determine if the integer is prime
  4. Keep running average of primes
  5. Print running average of primes (no formatting necessary)

Example 1:

Values.txt Prime Values Average
751 1090 971 1054 7 300 19 834 100 751 549 288 641 989 479 1388 1319 584 751 971 7 19 751 641 479 1319

617.2499999999999

Values.txt Prime Values Average
61 121 124 479 Blackberry 787 416 541 1011 Lemon 1051 493 827 140 Jackfruit 1103 Mango Blackberry 113 Blackberry 439 Orange Kiwi 1103 562 504 61 479 787 541 1051 827 1103 113 439 1103

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!