T
Tonytt
Hi,
I'm pretty new to c-programming and am taking a course in it. I'm
trying to write a menu program using functions and a two-dimensional
array. The program consists of entering 4 test grades for 10 students.
The array is initialized with -1 in the beginning - this is because if
a student did not take a test yet I want to be able to sort and find
this out. There is a menu option to enter grades which calls a
function in order to enter the student - 1-10, the test number 1-4 and
the grade. The problem I am running into is I want to display a
message to prompt the user that there is a grade already present if
the grade was entered before - and allow the user to replace the grade
or leave it as is. here is that part of the code:
int enterInfo (int, int, double)
{ while (1)
{
int Stud_Num,
Exam_Num,
Grade_Num,
response,
response1;
cout << "Please Enter a Student Number > ";
cin >> Stud_Num;
if ((Stud_Num <1) || (Stud_Num >10))
{
cout << "\n\nInvalid entry, Please try again! \n";
return Stud_Num;
}
else
cout << "\nPlease Enter an Exam Number > ";
cin >> Exam_Num;
if ((Exam_Num <1) || (Exam_Num >4))
{
cout << "\n\nInvalid entry, Please try again! \n";
return Exam_Num;
}
else
cout << "\nPlease Enter a Grade > ";
cin >> Grade_Num;
//if ((Grade_Num >=0) && (Grade_Num <=100))
//{
//cout << "\nStudent already has a grade entered for this exam. \n";
//cout << "\nDo you want to replace the grade? Enter 1 for Yes or 0
for no: \n ";
//cin >> response;
// if (response == 1)
// return Grade_Num;
// }
// else
// return response;
if ((Grade_Num <0) || (Grade_Num >100))
{
cout << "\n\nInvalid entry, Please try again! \n";
return Grade_Num;
}
else
cout << "\nDo you want to enter another grade?: \n";
cout << "\nEnter 1 for Yes or 0 for No > ";
cin >> response1;
if (response1 != 0)
int main();
else
return response1;
}
}
Can anyone please explain to me how to include this in my program or
what I'm doing wrong?
BTW - A working model is located at this website:
as.sunyorange.edu/~insttg/
55171EF C Programming
Grades Program With Multiple Function Calls
There is no source code but you're able to run the completed program
and understand what I'm trying to do. Thanks...
TonyT.
I'm pretty new to c-programming and am taking a course in it. I'm
trying to write a menu program using functions and a two-dimensional
array. The program consists of entering 4 test grades for 10 students.
The array is initialized with -1 in the beginning - this is because if
a student did not take a test yet I want to be able to sort and find
this out. There is a menu option to enter grades which calls a
function in order to enter the student - 1-10, the test number 1-4 and
the grade. The problem I am running into is I want to display a
message to prompt the user that there is a grade already present if
the grade was entered before - and allow the user to replace the grade
or leave it as is. here is that part of the code:
int enterInfo (int, int, double)
{ while (1)
{
int Stud_Num,
Exam_Num,
Grade_Num,
response,
response1;
cout << "Please Enter a Student Number > ";
cin >> Stud_Num;
if ((Stud_Num <1) || (Stud_Num >10))
{
cout << "\n\nInvalid entry, Please try again! \n";
return Stud_Num;
}
else
cout << "\nPlease Enter an Exam Number > ";
cin >> Exam_Num;
if ((Exam_Num <1) || (Exam_Num >4))
{
cout << "\n\nInvalid entry, Please try again! \n";
return Exam_Num;
}
else
cout << "\nPlease Enter a Grade > ";
cin >> Grade_Num;
//if ((Grade_Num >=0) && (Grade_Num <=100))
//{
//cout << "\nStudent already has a grade entered for this exam. \n";
//cout << "\nDo you want to replace the grade? Enter 1 for Yes or 0
for no: \n ";
//cin >> response;
// if (response == 1)
// return Grade_Num;
// }
// else
// return response;
if ((Grade_Num <0) || (Grade_Num >100))
{
cout << "\n\nInvalid entry, Please try again! \n";
return Grade_Num;
}
else
cout << "\nDo you want to enter another grade?: \n";
cout << "\nEnter 1 for Yes or 0 for No > ";
cin >> response1;
if (response1 != 0)
int main();
else
return response1;
}
}
Can anyone please explain to me how to include this in my program or
what I'm doing wrong?
BTW - A working model is located at this website:
as.sunyorange.edu/~insttg/
55171EF C Programming
Grades Program With Multiple Function Calls
There is no source code but you're able to run the completed program
and understand what I'm trying to do. Thanks...
TonyT.