bool BScStudent::hasStudentGraduated() // return 1 if the student Graduated by his points // { int intermediateCoursesPoints = 0; int sumPoints = 0; for (auto it = begin (getCourses()); it != end (getCourses()); ++it) { sumPoints += it->getCourse()->getCoursePoints(); // add all the regular points intermediateCoursesPoints += (it->getCourse()->getCourseLevel() == INTERMEDIATE ? it->getCourse()->getCoursePoints() : 0); } return (intermediateCoursesPoints >= 5 && sumPoints >= 20); //check if enought points }
int Layout::getCourseStrings( int aCourse ) const { switch ( mKind ) { case Kind::Renaissance: if ( aCourse == 1 ) return 1; else if ( aCourse > 1 && aCourse < getCourses() ) return 2; else return 0; case Kind::Baroque: if ( aCourse == 1 || aCourse == 2 ) return 1; else if ( aCourse > 2 && aCourse < getCourses() ) return 2; else return 0; default: return 0; } }
/* * main * * Carries out the main flow for user. Prompts user to input data to calculate GPA */ int main (int argc, char ** argv){ float grade_points; // total number of grade points int result; // temp variable for detecting success of user input int units; // number of credits taken int numCourses = 0; // number of courses struct course courses[MAX_COURSE]; // list of courses float gpa; //total GPA float semester_gpa; // semester GPA char c; // used to detect whether courses are needed to be entered char temp[50]; // temp variable to get user input from stdin //Start Program puts("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); // 80 puts("+ Welcome +"); puts("+ to +"); puts("+ GPA Calculator +"); puts("+-----------------------------------------------------------------------------+"); puts("+ RULES +"); puts("+ Follow the on screen prompts. +"); puts("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); puts("\n"); // Get Current Credits Taken puts("[1]\tEnter your total credits completed:\n\tThis can be found on your transcript named either as credits or units."); printf("\t"); fgets(temp, 50, stdin); // get user input result = sscanf(temp,"%d",&units); // format user input while (result != 1){ // Prompt if invalid input puts("\tRead failed. Please enter a valid number:"); printf("\t"); fgets(temp, 50, stdin); // read input again result = sscanf(temp,"%d",&units); // format user input } printf("\n\tYou entered: %d credits\n\n", units); // echo user input // Get Current Grade Points puts("[2]\tEnter your total grade points earned:"); puts("\t(Total grade points are the sum of the grade received in each course,\n\tmultiplied by the number of credits awarded for each course. This can\n\tbe found on your transcript named either as points or grade points.)"); printf("\t"); fgets(temp, 50, stdin); // get user input result = sscanf(temp,"%f",&grade_points); // format user input while (result != 1){ // Prompt if invalid input puts("\tRead failed. Please enter a valid number:"); printf("\t"); fgets(temp, 50, stdin); // read input again result = sscanf(temp,"%f",&grade_points); // format user input } printf("\n\tYou entered: %.3f grade points\n", grade_points); // echo user input and round to 3 decimal places printf("\n\tYour Current GPA: %.3f\n\n", grade_points/units); //Calculate current GPA; GPA = Grade Points/Credits Taken // Ask user if they want to enter courses puts("[3]\tPress 'y' to enter courses to calculate your estimated GPA.\n\tOtherwise press enter.\n"); printf("\t"); c = getchar(); if( c == 'y') { // if yes (c='y') then add courses getchar(); // clear input getCourses(courses, &numCourses); // get courses displayCourses(courses, numCourses); // display entered courses calculateGPA(courses, numCourses, grade_points, units, &gpa, &semester_gpa); // calculate new gpa printf("\nYour estimated semester GPA:\t%.3f\n\n", semester_gpa); // echo estimated semester gpa round to 3 decimal places printf("Your estimated total GPA:\t%.3f\n\n\n", gpa); // echo estimated gpa round to 3 decimal places } puts("Press Enter to Exit..."); // Prompt user to press enter before exiting so they can view results getchar(); return 0; }
QString TAEval::serveRequest(QString request, QString data) { //Then find the request here and delegate the data to the SQL to query the required info. if(request.compare("loginRequest") == 0){ qDebug() << "Login Request being processed" << endl; QString l = accessControl.logIn(data); if(l.contains("Instructor")) { return QString("Instructor"); } if(l.contains("TA")) { return QString("TA"); } if(l.contains("loggedin")) { return QString("loggedin"); } else return QString("false"); } else if (request.compare("semesterRequest") == 0) { qDebug() << "Semester Request being processed" << endl; StringList *semesters; if(getSemesters(data, semesters)) { QString result = listToString(*semesters); delete semesters; return result.isEmpty() ? "false" : result; } } else if (request.compare("coursesRequest") == 0) { qDebug() << "Courses Request being processed" << endl; QStringList info = data.split("|"); qDebug() << info.at(0) + " " + info.at(1) << endl; CourseList* c; if(getCourses(info.at(0), c, info.at(0), info.at(1))) { QString stringOfCourses = Course::listToString(*c); qDebug() << stringOfCourses << endl; delete c; return (stringOfCourses.isEmpty()) ? "false" : stringOfCourses; } } else if (request.compare("tasRequest") == 0) { qDebug() << "TAs Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) + " and " + info.at(1) << endl; TAList* t; if(getTAs(info.at(0), info.at(1), t)) { QString stringOfTAs = TA::listToString(*t);delete t; qDebug() << stringOfTAs << endl; return (stringOfTAs.isEmpty()) ? "false" : stringOfTAs; } } else if (request.compare("taskRequest") == 0) { qDebug() << "Task Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) + " and " + info.at(1) << " and " << info.at(2) << endl; TaskList* taskList; if(getTasks(info.at(0), info.at(1), info.at(2), taskList)) { QString stringOfTask = Task::listToString(*taskList); delete taskList; qDebug() << stringOfTask << endl; return (stringOfTask.isEmpty()) ? "false" : stringOfTask; } else return "false"; } else if (request.compare("taskCreateRequest") == 0) { qDebug() << "Create Task Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) + " and " + info.at(1) << " and " << info.at(2) + " and " + info.at(3) << " and " << info.at(4) << + " and " + info.at(5) << endl; QStringList begDateList = info.at(4).split("-"); QStringList dueDateList = info.at(5).split("-"); QDate begDate(begDateList.at(0).toInt(), begDateList.at(1).toInt(), begDateList.at(2).toInt()); QDate dueDate(dueDateList.at(0).toInt(), dueDateList.at(1).toInt(), dueDateList.at(2).toInt()); return createTask(info.at(0), info.at(1), info.at(2), info.at(3), begDate, dueDate) ? "true" : "false"; } else if (request.compare("taskEditRequest") == 0) { qDebug() << "Edit Task Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) + " and " + info.at(1) + " and " + info.at(2) + " and " + info.at(3) + "and " + info.at(4) << endl; QStringList begDateList = info.at(2).split("-"); QStringList dueDateList = info.at(3).split("-"); QDate begDate(begDateList.at(0).toInt(), begDateList.at(1).toInt(), begDateList.at(2).toInt()); QDate dueDate(dueDateList.at(0).toInt(), dueDateList.at(1).toInt(), dueDateList.at(2).toInt()); return editTask(info.at(0), info.at(1), begDate, dueDate, QString(info.at(4))) ? "true" : "false"; } else if (request.compare("taskDeleteRequest") == 0){ qDebug() << "DELETE Task Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) + " and " + info.at(1) << endl; return deleteTask(info.at(0), QString(info.at(1))) ? "true" : "false"; } else if (request.compare("editEvalRequest") == 0){ qDebug() << "Edit Evail Request being processed" << endl; QStringList info = data.split("|"); return enterEvaluation(info.at(0), info.at(1).toInt(), info.at(2), info.at(3).toInt()) ? "true" : "false"; } else if (request.compare("logOutRequest") == 0){ qDebug() << "LogOut Request being processed" << endl; QStringList info = data.split("|"); qDebug() << "Inst here is: " + info.at(0) << endl; return accessControl.logOut(info.at(0)) ? "true" : "false"; } qDebug() << "Request Failed" << endl; return "false"; }