Professional Documents
Culture Documents
#include <string.h>
#include <fstream>
if(x>y)
marks = (2*x+y)/3;
else
marks = (2*y+x)/3;
cout<<"The test marks considered for grading are : "<<marks;
return marks;
}
int menu()
{
int ch;
static int flag[4] = {0,0,0,0};
do {
cout<<"\nSelect a menu choice from the following options.\n";
cout<<"1. Project Marks\n";
cout<<"2. Lab Marks\n";
cout<<"3. Test Marks\n";
cout<<"4. Calculate total marks\n";
cout<<"> ";
cin>>ch;
if(ch > 4)
{
cout<<"This is an invalid menu choice. So please select the correct
choice.\n";
continue;
}
else if(ch == 4 && (flag[0] == 0 || flag[1] == 0 || flag[2] == 0))
{
cout<<"You should select all other choices before selecting this choice.";
}
else if(flag[ch-1] == 1)
{
cout<<"This menu choice is already selected. Please select a choice which is
not selected yet.\n";
}
else
{
flag[ch-1] = 1;
return ch;
}
}while(1);
}
int main()
{
double test1, test2, total_marks, average_of_labs, weighthed_mean,
best_of_project;
double lab[10], project[10];
int no_of_labs=5, no_of_projects=3, choice=0;
char grade;
char name[30], comments[30];
get_name(name);
while(choice<4)
{
choice = menu();
switch(choice)
{
case 1: best_of_project = get_project_marks(project, no_of_projects);
break;
case 2: average_of_labs = get_lab_marks(lab, no_of_labs);
break;
case 3: weighthed_mean = get_test_marks(test1, test2);
break;
case 4: total_marks = get_total(average_of_labs, best_of_project,
weighthed_mean);
get_grade(total_marks, grade, comments);
print(test1, test2, lab, no_of_labs, project, no_of_projects,
weighthed_mean, best_of_project, average_of_labs, total_marks, grade, comments,
name);
}
}