I'm running into errors with my code and I don't know how to fix it. The problem that I'm doing is below:
For example, you have been creating the function main since the beginning, and it is a function without parameters. Using this information, write a function called getLabGrades that prompts the user for each assignment grade (there are 5). Remember that each lab is worth 120 points. Use the following code in main to call it:
int main() {
double labs = getLabGrades();
cout << "Your lab grade is: " << labs << endl;
return 0;
}
Sample output:
Please enter best grade for lab 1: 100
Please enter best grade for lab 2: 95
Please enter best grade for lab 3: 90
Please enter best grade for lab 4: 85
Please enter best grade for lab 5: 80
Lab grade: 540
Your lab grade is: 540
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
|
#include <iostream>
#include <string>
#include <time.h>
using namespace std;
int getLabGrades(){
const int NUMLABS = 5;
double grade[NUMLABS];
for ( int x = 0; x < NUMLABS; x++){
grade[x] = 0;
cout << "Please enter best grade for lab " << NUMLABS << ": ";
cin >> grade[x];
{
grade[x] = 0;
cout << "Please enter best grade for lab " << NUMLABS << ": ";
cin >> grade[x];
}
}
int main(){
double labs = getLabGrades();
cout << "Your lab grade is: " << labs << endl;
return 0;
}
| |