Mar 3, 2015 at 4:29am UTC
I Keep getting this error message, and i'm sure it has something to do with how I am attempting to call my functions. I have been at this for hours, what am I doing wrong?
error: expected initializer before ‘double’
double tsav(int tstotal,int tsgradecounter, int grade)
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
double qzav(int qztotal,int qzgradecounter, int grade)
double tsav(int tstotal,int tsgradecounter, int grade)
double hwav(int hwtotal,int hwgradecounter, int grade)
int main()
{
int option; //option for menu
string lastname;
string firstname;
double qzaverage= qzav(qztotal,qzgradecounter,grade);
double tsaverage= tsav(tstotal,tsgradecounter,grade);
double hwaverage= hwav(hwtotal,hwgradecounter,grade);
do
{
cout << "1) Average grades for a new student:" <<endl; //menu for average
cout << "2) Quit program" <<endl; //option to quit
cout << "Please select an option"; //prompt user to select menu option
cin >> option; //print option
if(option == 1)
{
cout<<"Enter students first name";
cin>> firstname;
cout<<"Enter students last name"<<endl;
cin>> lastname;
cout>> "Quiz">> endl;
cin<< qzaverage;
cout>>"Test">> endl;
cin<< tsaverage;
cout>>"Homework">> endl;
cin<< hwaverage;
}
else if(option ==2)
{
cout<< "terminating program";
}
}
while(option != 2);
}
double qzav(int qztotal,int qzgradecounter,int grade)
{
int qztotal=0;
int qzgradecounter=0;
int grade;
cout>> "Quiz averager";
cout<< "Enter Quiz grade or -1 to quit:"; //propmt to enter qz grade
cin>> grade;
while (grade != -1)
{
qztotal= qztotal + grade; //total quiz grade
qzgradecounter= qzgradecounter + 1;
cout<< "Enter Quiz grade or -1 to quit:";
cin>> grade;
}
if (qzgradecounter !=0)
{
qzaverage= static_cast<double>(qztotal)/ qzgradecounter;
cout<<"total of all grades" <<qztotal<< endl;
cout<< "Quiz average is" << setprecision(2)<<fixed<<qzaverage<< endl;
}
else
cout << "No Grades were entered"<< endl;
return qzaverage;
}
}
double tsav(int tstotal,int tsgradecounter, int grade)
{
int tstotal=0;
int tsgradecounter=0;
int grade; //actual grade
cout<< "Enter Test grade or -1 to quit:";
cin>> grade;
while (grade != -1)
{
tstotal= tstotal + grade;
tsgradecounter= tsgradecounter + 1;
cout<< "Enter Test grade or -1 to quit:";
cin>> grade;
}
if (tsgradecounter !=0)
{
tsaverage= static_cast<double>(tstotal)/ tsgradecounter;
cout<<"total of all grades" <<tstotal<< endl;
cout<< "Test average is" << setprecision(2)<<fixed<<tsaverage<< endl;
}
else
cout << "No Grades were entered"<< endl;
return tsaverage
}
}
double hwav(int hwtotal,int hwgradecounter, int grade)
{
int hwtotal=0; //quiz total
int hwgradecounter=0; //number of grades
int grade; //actual grade
cout<< "Enter Homework grade or -1 to quit:";
cin>> grade;
while (grade != -1)
{
hwtotal= hwtotal + grade;
hwgradecounter= hwgradecounter + 1;
cout<< "Enter Homework grade or -1 to quit:"; //propmpt to enter hw grade
cin>> grade;
}
if (hwgradecounter !=0)
{
hwaverage= static_cast<double>(hwtotal)/ hwgradecounter;
cout<<"total of all grades" <<hwtotal<< endl;
cout<< "Homework average is" << setprecision(2)<<fixed<<hwaverage<< endl;
return hwaverage;
}
}
Mar 3, 2015 at 4:45am UTC
please use code tags. look at line one. thats where the error is.