I am trying to make a program with a menu, using a switch statement. It contains arrays to store numbers. I am in the early stages and have hit a brick wall and just need some assistance with getting past it.
Problem:
I cannot get any display in cmdpromt once I have entered a menu selection outside of my case 1:. I'll be honest, my code probably doesn't look the best as I have tryed so many things that I am now at whits end.
N.B: everything below compiles. I know what I need to do within to make it add a mark but nothing is showing on the screen!!
Please respond with question and suggestions. Thank you!
int SID = 0;
int StudM = 0;
// global statements above.
void AddMark(double StudM[], int StudCount[], int TotalM);
// prototypes above.
int main ()
{
int loop=1;
int choice;
while (loop==1)
{
system ("CLS"); //Question 3
cout << " ** MENU **\n\n"
<< "0. Exit \n"
<< "1. Add Student mark \n"
<< "2. List all student marks \n"
<< "3. Calculate the marks average \n"
<< "4. Calculate the standard deviation \n"
<< "5. Delete a student mark \n"
<< "6. find the number of students via mark \n"
<< "7. Display distinct marks and their occurrences \n";
cout << "\n\nSelect from the menu above: ";
cin >> choice;
switch(choice)
{
case 0:
cout << "Good bye\n\n";
system ("pause");
exit(0);
case 1:
system ("CLS");
void AddMark(double StudM, int StudCount, int TotalM); //Add Student mark.
system ("pause");
system ("CLS");
main();
break;
case 2:
system("CLS");
cout << "\t-- List all student marks --\n\n";
system ("pause");
system("CLS");
break;
case 3:
system("CLS");
cout << "\t-- Calculate the marks average --\n\n";
system ("pause");
system("CLS");
break;
case 4:
system("CLS");
cout << "\t-- Calculate the standard deviation --\n\n";
system ("pause");
break;
case 5:
system("CLS");
cout << "\t-- Delete a student's mark --\n\n";
system ("pause");
system("CLS");
break;
case 6:
system("CLS");
cout << "\t-- Find the number of students via a mark --\n\n";
system ("pause");
system("CLS");
break;
case 7:
system("CLS");
cout << "\t-- Display distinct marks and thei occurrences --\n\n";
system ("pause");
system("CLS");
break;
}
}
}
// 1. Add a student mark!
void AddMark(double StudM, int StudCount, int TotalM){
system("CLS");
cout << "\t-- Add Student Mark --\n\n";
cout << "Enter mark: " <<endl;
cin >> StudM;
system ("pause");
3. you're calling your function wrongly in main(): void AddMark(double StudM, int StudCount, int TotalM); //Add Student mark. -refer to the function tutorials in (2)