Vector Help

Hi I am asked to write a program that keeps track of students results in a vector. I am to assume that there will no more than 10 results but there may be less, I also must use a loop. A letter grade must be assigned to the input for example Grade a would be from 90-100. I think I have the basic framework but I am not sure how to get out the loop and ask the user to input something else..

Help would be appreciated.

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
  #include<iostream>
#include<vector>
#include<iomanip>
using namespace std;

double getSum(vector<double>vecThisSum);

int main()
{
	vector<double>gradeinput(10);
	double doubleresult=0;
	double ginput;
	cout<<"Enter result 1 (or -1 if no more result): ";
	cin>>ginput;
	if (ginput != -1 && ginput<100 && ginput>0)
	{
		for (int i = 0; i<gradeinput.size(); i++)
	{
		gradeinput [i]= ginput;
	}
	doubleresult = getSum(gradeinput);
		cout << "The sum is "<<doubleresult<<endl;
	}
	else
	{
		cout<<"Invalid input"<<endl;
	}
	
	system("Pause");
	return 0;
}

double getSum (vector <double> vecThisSum)
{
	double intSum=0;
	for (int i = 0; i<vecThisSum.size() ; i++)
	{
		intSum=intSum+vecThisSum[i];
	}
	return intSum;
}

Topic archived. No new replies allowed.