Answer to Question #285556 in C++ for biu

Question #285556

Write a C++ program that will: 5.1 Accept student’s information into three parallel arrays. The capture of the students’ marks must be a sentinel-controlled mark that is below zero for either the continuous assessment (term) mark or the final mark. Use a sentinel-controlled loop that will exit when the user types in the word ’Done’ instead of a student’s name. For each mark, use a function: int validateData(string,int) that receives a message to be displayed to the user in case the mark is not acceptable, and also the captured mark. Marks can only be between 0 and 100.


1
Expert's answer
2022-01-08T01:34:41-0500
using namespace std;




/*
	Write a C++ program that will: 
	5.1 Accept student’s information into three parallel arrays. 
	The capture of the students’ marks must be a sentinel-controlled mark that is below zero for either 
	the continuous assessment (term) mark or the final mark. Use a sentinel-controlled loop that will 
	exit when the user types in the word ’Done’ instead of a student’s name. For each mark, use a function: 
	int validateData(string,int) that receives a message to be displayed to the user in case the mark is not acceptable, 
	and also the captured mark. Marks can only be between 0 and 100.
*/


#define NO_OF_STUDENTS	100
int FlagName=1,FlagMarks_1=0,FlagMarks_2=0,Flag=1;
void validateData(string s, int m, int n)
{
	if(s=="done") FlagName=0;
	if(m<0 || m>100) FlagMarks_1=0;	else FlagMarks_1=1;
	if(n<0 || n>100) FlagMarks_2=0;	else FlagMarks_2=1;
}


int main()
{
	int n=0,m;
	string Name[NO_OF_STUDENTS];
	string s="";
	int Marks_1[NO_OF_STUDENTS],Marks_2[NO_OF_STUDENTS];
	
	while(FlagName)
	{
		FlagName==1 && FlagMarks_1==0 && FlagMarks_2==0;
		while(FlagName==1 && FlagMarks_1==0 && FlagMarks_2==0)
		{
			cout<<"Student ID = "<<n+1<<"\tName: "; cin>>Name[n];
			cout<<"\Enter Term Marks-1 (0-100): ";	cin>>Marks_1[n];
			cout<<"\Enter Term Marks-2 (0-100): ";	cin>>Marks_2[n];
			validateData(Name[n],Marks_1[n],Marks_2[n]);
		}
		n++;
	}
	for(m=0;m<n;m++)
	{
		cout<<"\nName: "<<Name[m]<<"\tTerm Marks: "<<Marks_1[m]<<"\tFinal Marks: "<<Marks_2[m];
	}
	return(0);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment