I'm trying to make a grading system.So what i want to do is take 1/3 of the value of outputgrade
and add it with 2/3 of the value of outputgrade2
, I tried midterm1=(outputgrade()*1/3)+(outputgrade2*2/3)
but I receive an error which is
Not an allowed type
Please somebody help me on what to do.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
double AAO,Quizzes,Project,MajorExam,Midterm;
void inputprelim()
{
clrscr();
gotoxy(3,4);cout<<"Input Prelim Grade";
gotoxy(1,6);cout<<"Attendance/Ass./Oral: ";cin>>AAO;
gotoxy(1,7);cout<<"Project: ";cin>>Project;
gotoxy(1,8);cout<<"Quizzes: ";cin>>Quizzes;
gotoxy(1,9);cout<<"Major Exam: ";cin>>MajorExam;
gotoxy(1,11);cout<<"Prelim Grade: ";
}
int getgrade(double a, double b, double c, double d)
{
double result;
result=(a*0.10)+(b*0.20)+(c*0.30)+(d*0.40);
cout<<setprecision(1)<<result;
return result;
}
void outputgrade()
{
getgrade(AAO,Project,Quizzes,MajorExam);
getch();
}
void inputmidterm()
{
gotoxy(33,4);cout<<"Input Midterm Grade";
gotoxy(29,6);cout<<"Attendance/Ass./Oral: ";cin>>AAO;
gotoxy(29,7);cout<<"Project: ";cin>>Project;
gotoxy(29,8);cout<<"Quizzes: ";cin>>Quizzes;
gotoxy(29,9);cout<<"Major Exam: ";cin>>MajorExam;
gotoxy(29,11);cout<<"Temporary Midterm Grade: ";
gotoxy(29,12);cout<<"Final Midterm Grade: ";
}
void outputgrade2()
{
getgrade(AAO,Project,Quizzes,MajorExam);
getch();
}
void main()
{
inputprelim();
gotoxy(15,11);outputgrade();
inputmidterm();
gotoxy(54,11);outputgrade2();
gotoxy(55,11);
Midterm1=(outputgrade()*1/3)+(outputgrade2()*2/3);
}
Your functions outputgrade()
and outputgrade2()
are of return type void
.
In order to use them in midterm1=(outputgrade()*1/3)+(outputgrade2*2/3)
you need to change their return type as int/double/float,etc.
If I have understood the logic of your code correctly then edit the two functions as:
double outputgrade()
{
return getgrade(AAO,Project,Quizzes,MajorExam);
}
double outputgrade2()
{
return getgrade(AAO,Project,Quizzes,MajorExam);
}
What I have done is changed the return type to double
and at the same time the two functions are now returning whatever value getgrade
returns.