getCommand(add_student(id(1), name(last(smith), first(joe), middle(_)),major(cs),active(yes))). getCommand(add_student(id(2), name(last(anderson), first(edgar), middle(van)),major(cs),active(yes))). % error: student already in database getCommand(add_student(id(1), name(last(_), first(_), middle(_)),major(_),active(_))). getCommand(add_student(id(3), name(last(smith), first(nick), middle(_)),major(chem),active(_))). getCommand(add_student(id(4), name(last(dumars), first(joe), middle(_)),major(math),active(no))). getCommand(find_students(id(_), name(last(_), first(_), middle(_)), major(_), active(_), Student_ID_List)). /* the database now has 4 students ID LNAME FNAME MNAME MAJOR ACTIVE ----------------------------------------- 1 smith joe cs yes 2 anderson edgar van chem yes 3 smith nick cs yes 4 dumars joe math no */ getCommand(add_exam(id(cs141), name(algorithms), weight(0.3), max(_), active(yes))). getCommand(add_exam(id(cs181), name(languages), weight(0.2), max(39), active(_))). % error: exam already in the database getCommand(add_exam(id(cs141), name(_), weight(0.6), max(80), active(yes))). getCommand(add_exam(id(cs170), name(ai), weight(0.3), max(_), active(_))). getCommand(add_exam(id(cs10), name(programming), weight(0.2), max(50), active(yes))). getCommand(add_exam(id(cs20), name(_), weight(0.1), max(_), active(no))). /* the database now has 5 students ID NAME WEIGHT MAX ACTIVE ----------------------------------------- cs141 algoriths 0.3 100 yes cs181 languages 0.2 39 yes cs170 ai 0.3 100 yes cs10 programming 0.2 50 yes cs20 0.1 100 no */ % error: unknown student getCommand(add_grade(student_id(8), exam_id(cs141), grade(10), active(yes))). % error: unknown exam getCommand(add_grade(student_id(1), exam_id(cs50), grade(70), active(yes))). % error: grade > max getCommand(add_grade(student_id(1), exam_id(cs181), grade(60), active(yes))). getCommand(add_grade(student_id(1), exam_id(cs141), grade(90), active(yes))). getCommand(add_grade(student_id(1), exam_id(cs181), grade(30), active(yes))). getCommand(add_grade(student_id(1), exam_id(cs170), grade(80), active(no))). getCommand(add_grade(student_id(2), exam_id(cs141), grade(95), active(yes))). getCommand(add_grade(student_id(2), exam_id(cs10), grade(45), active(yes))). getCommand(add_grade(student_id(3), exam_id(cs20), grade(65), active(yes))). getCommand(add_grade(student_id(4), exam_id(cs141), grade(60), active(yes))). /* grades SID EID GRADE ACTIVE ------------------------------------- 1 cs141 90 yes 1 cs181 30 yes 1 cs170 80 no 2 cs141 95 yes 2 cs10 45 yes 3 cs20 65 yes 4 cs141 60 yes */ % error: unknown student getCommand(update_student(id(7),name(last(_), first(_), middle(_)), major(_),active(_))). getCommand(update_student(id(1),name(last(smithson), first(_), middle(_)), major(ece),active(_))). % error: unknown exam getCommand(update_exam(id(cs55), name(_), weight(_),max(40),active(_))). getCommand(update_exam(id(cs181), name(prolog), weight(_),max(40),active(_))). % error: grade > max getCommand(update_grade(student_id(1), exam_id(cs181), grade(100), active(_))). % error: unknown student getCommand(update_grade(student_id(6), exam_id(cs141), grade(85), active(_))). % error: student has not taken this exam getCommand(update_grade(student_id(1), exam_id(cs10), grade(10), active(_))). getCommand(update_grade(student_id(1), exam_id(cs141), grade(95), active(_))). getCommand(student_grades(student_id(1), Grade_List)). %should print [(cs141, 95), (cs181, 30)] getCommand(exam_grades(exam_id(cs141), Grade_List)). %should print [(1,95), (2,95)] getCommand(total_grade(student_id(1), Total_Grade)). %should print 87 %the result is 100*(0.3*95/100 + 0.2*30/40)/(0.3+0.5) getCommand(mean_grade(exam_id(cs141), Mean_Grade)). %should print 95 %because there are to active students(1,2) who both have the same grade 95