Question: //How Call Function void registerStudent and void updateAssestment in main function? #include #include #include #include using namespace std; struct LikeAG6{ string idNo; float test,quiz,quiz1=0,quiz2=0,quiz3=0; LikeAG6(){
//How Call Function "void registerStudent" and "void updateAssestment" in main function? #include#include #include #include using namespace std; struct LikeAG6{ string idNo; float test,quiz,quiz1=0,quiz2=0,quiz3=0; LikeAG6(){ test = 0; } }; int menu() { int choice; cout << " CARRY MARK PROGRAM "; cout << "1. Add New Student "; cout << "2. Update Assessment "; cout << "3. Carry Mark Summary "; cout << "4. Carry Mark Summary (Save to File) "; cout << "5. Exit "; cout << "Enter choice: "; cin >> choice; return choice; } //Same data type with pointer void registerStudent(/*LikeAG6 *newStud*/ vector & student) { LikeAG6 s; cout << " Enter student ID: "; //cin >>ws; //Remove white screen buffer cin >> s.idNo; bool repeat = true; while (repeat){ int choice = menu(); if (choice == 1){ if (s.quiz1 !=0 || s.quiz2 !=0 || s.quiz3 !=0){ cout << " Quiz mark already exists Choose UPDATE option in MAIN MENU to update " ; } else { cout << "Enter Quiz1 mark (15) : "; cin >> s.quiz1; cout << "Enter Quiz2 mark (15) : "; cin >> s.quiz2; cout << "Enter Quiz3 mark (15) : "; cin >> s.quiz3; } } else{ cout << "Invalid Input"; } string addA; cout << " Add another assessment [Y/N] : "; cin >> addA; if (addA == "N" || addA == "n") repeat = false; } student.push_back(s); } int findStudent(vector student, string ID){ for (int i = 0; i < student.size(); i++){ if (student[i].idNo == ID){ return i; } } return -1; } void updateAssestment(vector & s){ //LikeAG6 *newStud = registerStudent(); int option; //,totalquiz,totalquizzes,totaltest,totalassignment,totallabtest,totalcarrymark; string ID; cout << " Enter student ID: "; cin >> ID; float totalquiz = 0; char answer; int pos = findStudent(s, ID); if (pos == -1){ cout << " Student ID not Exist. " << endl; } else{ bool repeat = true; while(repeat){ int choice = menu(); if(choice == 1){ cout << "Quiz1 mark (15) : " << s[pos].quiz1 << " "; cout << "Quiz2 mark (15) : " << s[pos].quiz2 << " "; cout << "Quiz3 mark (15) : " << s[pos].quiz3 << " "; } } } /*cin >>ws; //Remove white screen buffer for(int i=0;i > option; cout << endl; switch (option){ case 1: cout << "Enter Quiz1 mark (15) : " << Record[pos].quiz1; cin >> Record[pos].quiz1; cout << "Enter Quiz2 mark (15) : "; cin >> Record[pos].quiz2; cout << "Enter Quiz3 mark (15) : "; cin >> Record[pos].quiz3; totalquiz = Record[pos].quiz1 + Record[pos].quiz2 + Record[pos].quiz3; cout << "Total Quiz mark (45m) : " << totalquiz; //totalquiz = (newStud->quiz/45)*15; cout << " Percentage of Quiz is " << setprecision(4) << (totalquiz / 45.0) * 15 << "%"; cout << endl << endl; break; default: break; } cout << " Add another assessment [Y/N] : "; cin >> answer; }while ((answer == 'y' || answer=='Y')); } else{ cout << " Student ID not Exist. " << endl; } }*/ } void CarryMarkSummary(vector Record) { int option, flag=0; string ID; cout << " Display Menu: "; cout << "1.Individual 2.All 3.Highest carry mark "; cout << "Select option: "; cin >> option; if(option == 1) { cout << "Enter Student ID: "; cin >> ID; for(int i=0;i student; //datatype make sure sama dgn struct LikeAG6 newStud; //Struct Object; int choice; do { choice = menu(); switch (choice) { case 1: //call function registerStudent() and push the data to vector. //registerStudent(student); //Record.push_back(student); //push dalam group break; case 2: //call function deleteBook() //updateAssestment(Record); //updateAssestment(Record); break; case 3: //call function CarryMarkSummary //CarryMarkSummary(Record); break; case 4: //call function CarryMarkSummarytxt //CarryMarkSummarytxt(); break; case 5: cout << " Thank You Don't Come Again :D "; return 0; default: cout << " >_< Tengok betul betul pls "; //system("CLS"); break; } } while (choice != 5); }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
