Beispiel #1
0
int main(void){
  Student st[20];
  int nrOfStudents;
  int option = 0;
  while (option != 5) {
    option = menu();
    switch (option){
      case 1:
        cin.ignore();
        addStudent(st, nrOfStudents);
        break;
      case 2:
        showAllStudents(st, nrOfStudents);
        break;
      case 3:
        cin.ignore();
        if(removeStudent(st, nrOfStudents) != -1)
          cout << "Succesful!\n";
        break;
      case 4:
          int position;
          position = findStudent(st, nrOfStudents);
          if(position != -1){
            st[position].show();
          }
          else
            cout << "Not found\n";
        break;
      }
  }
  return 0;
}
Beispiel #2
0
void MainWindow::on_actionFindStudent_triggered()
{
    fStudentDialog = new findStudentDialog(student,this);
    connect(fStudentDialog, SIGNAL(accepted()), this, SLOT(updateTableView()));
    connect(fStudentDialog, SIGNAL(accepted()), this, SLOT(findStudent()));
    fStudentDialog->show();
}
Beispiel #3
0
void StudentList::searchByStudentId()
{
	int id;

	cout << "학생의 학번을 검색합니다." << endl;
	
	cout << "검색할 학생의 학번을 입력하시오 : ";
	cin >> id;

	selectDisplayStudent(findStudent(id));	// 탐색한 학생을 출력
}
Beispiel #4
0
bool removeStudent(Student st[], int &nrOfStudents){
    bool isRemoved = false;
    int position = -1;
   cout << "Enter name to search: " << endl;
    position = findStudent(st, nrOfStudents);
        if(position != -1){
          st[position] = st[nrOfStudents];
          isRemoved = true;
          nrOfStudents--;
        }
    return isRemoved;
}
Beispiel #5
0
void TaskManager::changeStudent(StudentList& s_list)
{
	ioHandler ioh;

	ioh.putString(" 학생 정보를 수정합니다 ");

	int id = ioh.getInteger(" 수정할 학생의 학번을 입력하시오 : ");
	ioh.putString(" 다음 학생의 정보를 수정합니다 ");

	Student s = ioh.getStudent();
	s_list.updateStudent(findStudent(s_list, id), s); // 검색 후 지정된 id의 정보를 기준으로 생성자를 삽입하는 함수를 호출
}
Beispiel #6
0
void TaskManager::unregisterStudent(StudentList& s_list)
{
	ioHandler ioh;

	ioh.putString(" 학생 정보를 삭제합니다 ");

	int id = ioh.getInteger(" 삭제할 학생의 학번을 입력하시오 : ");

	for (int i = findStudent(s_list, id); i < s_list.getCount(); i++)
	{
		s_list.deleteStudent(i); // 전의 공간에 다음 공간을 덮어 씌워주는 배열 함수를 호출
	}
}
int MainWindow::gotText()
{
    QString name = this->findName(ui->numberEntry->text().toInt());

    ui->numberEntry->setText("");
    if(name==NULL)
    {
        ui->log->append("Invalid ID: Please try again");
        return 0;

    }
    Student *currStudent = findStudent(name); //gets the student object

    name = currStudent->getName();  //really redundant fix soon please
    QString time = (QTime::currentTime().toString());
    //int date = (const int QDate::month());
    QString date = QDate::currentDate().toString();

    if (!currStudent->isSignedIn())
    {   //if the user is not signed in

        currStudent->setSignedIn(true);   //sign him in
        ui->log->append("Signed in: " + name);
        currStudent->getLastSignIn()->start();  //and start the timer for how long he is there

        QFile file("data.csv");

        QFileInfo fileInfo("data.csv");
        //ui->log->append(fileInfo.absoluteFilePath());

        if (file.open(QFile::WriteOnly|QFile::Append))
        {
            QTextStream stream(&file);
            stream << name << "," << time <<"," << "Sign In," << date << "\r\n"; // this writes first line with two columns
            file.close();
        } else {
            ui->log->append("This shit don't work");
        }

    }
    else if (currStudent->isSignedIn()) {   //if the user is signed in

        currStudent->setSignedIn(false);  //sign him out
        int elapsed = currStudent->getLastSignIn()->elapsed();  //magically get the numbers for how long he has been there
        int seconds = (int) (elapsed / 1000) % 60 ;
        int minutes = (int) ((elapsed / (1000*60)) % 60);
        int hours   = (int) ((elapsed / (1000*60*60)) % 24);
        ui->log->append("Signed out: " + name + " || Duration: " +  QString::number(hours)+ ":" + QString::number(minutes) + ":" +  QString::number(seconds));  //display it to him
        currStudent->getLastSignIn()->restart();    //and restart the timer?


        QFile file("data.csv");
        if (file.open(QFile::WriteOnly|QFile::Append))
        {
            QTextStream stream(&file);
            stream << name << "," << time <<"," << "Sign Out," << date << "\r\n"; // this writes first line with two columns
            file.close();
        }

        //if(currStudent->getLastSignIn()->elapsed()==0 || (currStudent->getCorrectSignIn() && currStudent->getLastSignIn()->elapsed()>57600000))
        //    {
        //        currStudent->setCorrectSignOut(false);
        //        ui->log->append("Signed in: " + name);
        //        currStudent->getLastSignIn()->start();
        //    }
        //    else if(!currStudent->getCorrectSignIn() && currStudent->getLastSignIn()->elapsed()>57600000)//57600000 //16 hours in millesonds
        //    {
        //        currStudent->setCorrectSignOut(false);
        //        ui->log->append("You did not sign-out last time, resigning-in");
        //        ui->log->append("Signed in: " + name);
        //        currStudent->getLastSignIn()->restart();
        //    }

        //    else if(currStudent->getLastSignIn()->elapsed()<5400000)//5400000   //1 hour 30 minutes in seconds
        //    {
        //        int elapsed = currStudent->getLastSignIn()->elapsed();
        //        int seconds = (int) (elapsed / 1000) % 60 ;
        //        int minutes = (int) ((elapsed / (1000*60)) % 60);
        //        int hours   = (int) ((elapsed / (1000*60*60)) % 24);
        //        ui->log->append("Signed out: " + name + " || Duration: " +  QString::number(hours)+ ":" + QString::number(minutes) + ":" +  QString::number(seconds));
        //        currStudent->getLastSignIn()->restart();
        //    }
        //    else if(currStudent->getLastSignIn()->elapsed()>5400000)
        //    {
        //        currStudent->setCorrectSignOut(true);
        //        int elapsed = currStudent->getLastSignIn()->elapsed();
        //        int seconds = (int) (elapsed / 1000) % 60 ;
        //        int minutes = (int) ((elapsed / (1000*60)) % 60);
        //        int hours   = (int) ((elapsed / (1000*60*60)) % 24);
        //        ui->log->append("Signed out: " + name + " || Duration: " +  QString::number(hours)+ ":" + QString::number(minutes) + ":" +  QString::number(seconds));
        //        currStudent->getLastSignIn()->restart();
        //        this->manager->changeStatus(name);
        //    }
    }
    return 1;

}
Beispiel #8
0
int main(int argc, char* argv[])
{
    Student studer = findStudent(argv[1],3);
    printf("%.20f\n",studer.gpa);
    return 0;
}
Beispiel #9
0
/* * * * * * * * * * * * * * * * * * * * * * * * *
		Main Program:
		Display menu, get and run user choice.
* * * * * * * * * * * * * * * * * * * * * * * * */
int main()
{
	int choice = 0;	// store user selection
	int quit = 0;	// flag to end program
	
	// print the menu, loop until user quits
	do {
		printf("\n\nWelcome to STUDENTS!\n===================\n\n"
			"There are currently %d students in memory.\n\n"
			"1.  Add New Student(s)\n"
			"2.  Find Student by Last Name\n"
			"3.  List All Students\n"
			"4.  Sort Database\n"
			"5.  Load Students File (./students.dat)\n"
			"6.  Save Students File (./students.dat)\n"
			"7.  Clear Memory (New Database)\n"
			"8.  Quit\n\n", numStudents);
		
		// input the user selection
		choice = inputInteger("Choice: ");
		printf("\n");
		
		// run the appropriate function based on user choice
		switch (choice)
		{
			case 1: // add
				addStudents();
				break;
			case 2: // find
				findStudent();
				break;
			case 3: // list
				listStudents();
				break;
			case 4: // sort
				sortStudents();
				break;
			case 5: // load
				if (numStudents == 0 || confirm("LOAD file and LOSE all students in memory (y/n) ? "))
					loadStudents();
				break;
			case 6: // save (only if students[] is not empty)
				if (numStudents == 0) printf("There are no students to save yet!\n");
				else if (confirm("OVERWRITE the file (y/n) ? "))
					saveStudents();
				break;
			case 7: // new
				if (confirm("DELETE all students from memory (y/n) ? "))
					clearStudents();
				break;
			case 8: // quit
			default: // quit
				if (confirm("QUIT and LOSE all data in memory (y/n) ? "))
				{
					printf("\nThank you and goodbye!\n\n");
					quit = 1;
				}
				break;
		}
	} while (quit == 0);	// keep repeating until user chooses to quit
	
	// quit = 1: end program successfully
	#ifdef _MSC_VER
		getchar();
		getchar();
	#endif

	return 0;
}
Beispiel #10
0
int main(){
	student_t *head, *newStudent,*temp;
	int age,major; 
	float gpa;
	char * name, *name1, cr;
	char *msg;
	int i;
	int answer,data;
	
	head = NULL;
	printf("You are now entering the student zone!\n");

	answer = menu();
	while(answer != 7){
		switch (answer) {
			case 1:
				printf("enter age:\n");
				scanf("%d%c",&age,&cr);
				printf("enter gpa:\n");
				scanf("%f%c",&gpa,&cr);
				printf("enter major:\n");
				scanf("%d%c",&major,&cr);
				printf("enter name:\n");
				name = getline();
				//printf("length: %d\n",strlen(name));
				newStudent = createStudent(age, name,major,gpa);
				break;
			case 2:
				insertStudent(&head,newStudent);
				break;
			case 3:
				printf("enter student name to delete\n");
				name1 = getline();
				deleteStudent(&head,name1);
				free(name1);
				break;
			case 4:
				printf("enter student name to investigate\n");
				name1 = getline();
				data = dataMenu();
				switch (data) {
					case 1:
						temp = findStudent(head, name1);
						if(temp == NULL){
							printf("Student %s not found \n",name1);
							break;
						}
						age = getAge( temp);
						printf("The age of %s, is %d\n",name1,age);
						break;
					case 2:
						temp = findStudent(head, name1);
						if(temp == NULL){
							printf("Student %s not found \n",name1);
							break;
						}
						gpa = getGpa( temp);
						printf("The gpa of %s, is %f\n",name1,gpa);					
						break;
					case 3:						
						temp = findStudent(head, name1);
						if(temp == NULL){
							printf("Student %s not found \n",name1);
							break;
						}
						major = getMajor( temp);
						printf("The gpa of %s, is %d\n",name1,major);					
						break;
						
					default:
						break;
				}
				break;
			case 5:
				temp = head;
				while(temp != NULL){
					msg = toString( temp);
					printf("%s\n",msg);
					temp = temp->link;
				}
				break;
			case 6:
				insertStudentRear(&head,newStudent);
				break;			
			default:
				break;
		}
		answer = menu();
	}
	printf("BYE\n");
	return(0);

}