You will be given a file that will contain averages for classes which are divided into sections
Question:
You will be given a file that will contain averages for classes which are divided into sections in the following format. The name of this file will be "grades.txt".
A 93
B 82
A 86
C 75
F 83
You are to write a program that computes the averages for the sections of classes, they are divided into groups that are denoted by a capital letter. You are to use arrays to calculate the average. I recommend using two arrays one to keep a sum of the averages and the other a counter for how many classes have been added to the sum.
The equation for calculating the average is:
(sum of numbers in list) / (number of numbers in list)
Given this you can have one array to keep a sum of the numbers that you are given and the other to keep a count of the number of classes in that section. The section names will be from A - Z and will always be capital letters. The averages will be from 0 - 100 inclusively.
Your program should output to the console the highest average section, lowest average section, and the average score across all of the sections. Output both the section name and the score for that section. To a file you will print the average for each section in alphabetical order. Always output the scores with two decimal places.
HIGHEST AVERAGE:................A:98.00
LOWEST AVERAGE:.................H:73.00
AVERAGE SCORE:....................85.00
To a file named "results.txt":
A: 98.00
B: 93.00
C: 85.21
D: 95.12
.
.
.
Z: 78.25
Accounting Principles Volume 2
ISBN: 978-1119502555
8th Canadian Edition
Authors: Jerry J. Weygandt, Donald E. Kieso, Paul D. Kimmel, Barbara Trenholm, Valerie Warren, Lori Novak