how to calculate average of the price from files within the main function

hi can anyone help me with the code in how to find the average of the price from a txt file and display all the information of the book when the price is greater than the average price.The code should be within the main function(cannot use void or arrays)

here is the txt file
here is the order of the txt
author name bookname book no . price . quantity
damson Iain T. Data Structures and Algorithms 3540760474 59 2
Cormen Thomas H Introduction to Algorithms 0262032937 100 5
Drozdek Adam Data Structures and Algorithms 0534375979 201 3
Flamig Bryan Practical Data Structures i 047155863X 201 11
Ford William Data Structures with C++ Using 0130858501 64.99 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//compute the average
sum := 0
n := 0
while read the file:
   separate the fields
   sum := sum + price
   n := n+1
average := sum/n

//expensive books
reset the file
while read the file:
   separate the fields
   if price > average
      print(fields)
Topic archived. No new replies allowed.