Finding the average, lowest and highest value number etc in a list of numbers from a txt file

I have an assignment where I have to create a menu and then depending on the menu choice the program has to call from a list of numbers from a file and find the highest and lowest value, sum, average and number of values in the list. I think I almost have it figured it but im having trouble with the equations to get the values.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
 #include <iostream>
#include <fstream>
using namespace std;

int main()
{
	char choice; // To hold a menu choice

	// Constants for menu choices
	const char LARGE_CHOICE = 'A',
			   SMALL_CHOICE = 'B',
			   SUM_CHOICE = 'C',
			   AVERAGE_CHOICE = 'D',
			   TOTAL_CHOICE = 'E',
			   END_CHOICE = 'F';

	// Display the menu and get a choice
	cout << "Make a selection from the list\n"
	   	 << "A. Get the largest value\n"
		 << "B. Get the smallest value\n"
		 << "C. Get the sum of the values\n"
		 << "D. Get the average\n"
		 << "E. Get the number of values entered\n"
		 << "F. End this program\n\n"
		 << "Enter your choice -->  ";
	cin >> choice;

	ifstream inputFile;
	double sum = 0;
	double number;

	inputFile.open("random.txt");

	// Respond to the user's menu selection 
	if (choice == 'A' || choice == 'a')
	{
		for (int count = 0; inputFile >> number; count++)
		{
			
		}
		cout << "The largest value is " << sum << ".\n";
	}
	else if (choice == 'B' || choice == 'b')
	{
		for (int count = 0; inputFile >> number; count++)
		{
			
		}
		cout << "The smallest value is " << << ".\n";
	}
	else if (choice == 'C' || choice == 'c')
	{
		for (int count = 0; inputFile >> number; count++)
		{
			sum += number;
		}
		cout << "The sum of the values entered is " << sum << ".\n";
	}
	else if (choice == 'D' || choice == 'd')
	{
		for (int count = 0; inputFile >> number; count++)
		{
			
		}
		cout << "The average of the values entered is " << average << ".\n";
	}
	else if (choice == 'E' || choice == 'e')
	{
		for (int count = 0; inputFile >> number; count++)
		{
			
		}
		cout << "The number of values entered is " << << ".\n";
	}
	else if (choice == 'F' || choice == 'f')
	{
		for (int count = 0; inputFile >> number; count++)
		{
			
		}
		cout << "Program ending\n\n";
		<< "Press Enter to end -->  ";
	}
	else
		cout << choice << " is an invalid value.";

	inputFile.close();
		return 0;
}
1st store the element inside array
Next find sum, max, min, average wthout re-read the file
I havent learned about how to do arrays yet so I wouldnt be able to use it in my program.
Topic archived. No new replies allowed.