compiling only one error with program help

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
#include <iostream>

using namespace std;

double math(int test1, int test2, int test3, int avg){
    avg= (test1+test2+test3)/3.0;
}
void output (double avg1, char lg){
    cout<<"Your average is:"<< avg1;
}

void input(int &t1, int &t2, int &t3){
  cout<<"Enter test1"<<endl;
    cin>>t1;
   cout<<"Enter test2"<<endl;
    cin>>t2;
    cout<<"Enter test3"<<endl;
    cin>>t3;
}

{char {lettergrade (double average)};{

if (average>=93);{
    return (A);

else if (85<= average)&&(average <93);{
    return (B);
}

else if (76<= average)&&(average <85);{
    return (C);
}

else if(70<= average)&&(average <76);{
    return (D);
}
else (average<=69)&&(average<= 70);{
    return (F);


}

}

int main()
{
    int grade1;
    int grade2;
    int grade3;
    double average;
    char let;
    cout<<"Enter grade1:"<<endl;
    cin>>grade1;
    cout<<"Enter grade2:"<<endl;
    cin>>grade2;
    cout<<"Enter grade3:"<<endl;
    cin>>grade3;
    math(grade1, grade2, grade3, average);
    output (average);

return 0;{}
}




Compiling: C:\Users\KILL\Downloads\avg2.cpp
C:\Users\KILL\Downloads\avg2.cpp:21: error: expected unqualified-id before '{' token
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings


program is suppose to calculate the average from 3 test and give that average as a number and a letter grade.
I think you mean
 
char lettergrade (double average) {

EDIT: Oh and also you dont return anything in your math function so basically nothing happens.
1
2
3
double math(int test1, int test2, int test3) { //removed last parameter 
    return ((test1+test2+test3)/3.0);
}

^^ That should fix it
also in line 58 should probably be
 
    average = math(grade1, grade2, grade3); //removed last parameter  

Last edited on
Topic archived. No new replies allowed.