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:
- Read Lines from "Values.txt"
- Determine if the line is an integer
- Determine if the integer is prime
- Keep running average of primes
- 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
Get step-by-step solutions from verified subject matter experts
