ive wrote this program which inputs a score and gives a grade compared to the score,
well im half way there
but it wont run it asks me to put a semi colon next to a function which isnt correct
Could any1 help pls![]()
here u go
#include <iostream.h>
#include <conio.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h> //for strcpy library function
char Grade[5][14];
//function prototype
void welcomeScreen (void);
char batchScreen (void);
void getGrade(int mark, int total);
main()
{
char answer;
welcomeScreen();
answer = batchScreen();
while (answer=='y'||answer=='Y')
{
int totalMark[5], i;
for (i=0; i<5; i++)
{
cout<<"\nTotal mark for Assignments "<<(i+1)<<": ";
cin>>totalMark[i];
cout<<"Total Mark: "<<totalMark[i]<<"\t";
//call 'getGrade' passing in totalMark number and grade - 2 input parameters
getGrade(i, totalMark[i]);
cout<<"Grade: "<< Grade[i];
}
cout<<"\n\nSUMMARY OF GRADES:-\n\n";
for (i=0; i<5; i++)
cout<<"Total Mark: "<<totalMark[i]<<"\tGrade: "<<Grade[i]<<endl;
clrscr();
gotoxy(5, 2);
cout<<"Thank you for using this program";
getch ();
return 0 ;
}
//function definition
void welcomeScreen (void)
{
clrscr();
gotoxy(5, 2);
cout <<"Welcome to the student grading system\n\n";
gotoxy(5, 4);
cout<<"Press any key when you are ready \n";
gotoxy(5, 6);
getch();
}
char batchScreen (void)
{
char key;
clrscr();
gotoxy(5, 2);
cout<<"Do you want to process a batch of 5 students?";
gotoxy(5, 4);
cout<<"Enter y Or n \n";
gotoxy(5, 6);
cin>>key;
return key;
}
//get and validate user's mark
void getGrade(int mark, int total)
{
switch (total)
{
//Note the use of the 'strcpy' library function used to assign a new value to
//a string variable - cannot use the assignment operator '='
//to assign a new value to such a variable
case 1: strcpy(Grade[mark], "Merit");
break;
case 2: strcpy(Grade[mark], "Pass");
break;
case 3: strcpy(Grade[mark], "Fail");
break;
default: strcpy(Grade[mark], "Invalid Grade");
}
return;
};
}


LinkBack URL
About LinkBacks
Reply With Quote
