//6 Weeks Grading Book Project //Created By: Joshua Nixon, Alex Holiday, Elliot ? //This is a grading book project that will allow //a teacher to enter in the amount of student she //has and enter in the grades for them. #include #include #include #include #include class GradeBook { private: //Structure for the student gradebook struct Student_Info { char Password[10];//This will hold the password if they even have one int PwdCheck;//This will char StudentID[10];//This will hold the student\students ID char First[20];//This will hold the student\students First Name char Last[20];//This will hold the student\students Last Name int GradeLevel;//This will hold the student\students Grade Number double *Grades;//This will hold the student\students amount of Grades double *Test;//This will hold the student\students amount of Test Grades }; //Global Struct for program public: char* Teacher_Gender[3]; //Function to make the start up screen void Start_Up_Screen(int X, int Y); void View_Intructions(int Gender, char* Teacher_Name); void New_GradeBook();// New GradeBook void Load_GradeBook();// Load GradeBook void About_GradeBook();// About GradeBook //The constructor used to intailize the data for the variables GradeBook::GradeBook() { strcpy(Teacher_Gender[0],"Mr. "); strcpy(Teacher_Gender[1],"Miss. "); strcpy(Teacher_Gender[2],"Mrs. "); } //deconstructor used to give the memory back to the program }; int main() { GradeBook GB;//Intailize the class // X Y GB.Start_Up_Screen(79,23);//Create the simple interface GB.View_Intructions(2,"TeacherName"); return 0; } //*************************************************************** //This function will take the X,Y and draw the UI(User Interface) //The third argument is used for the teacher gender(respect) //The Fourth argument is the Last or First Teachers Name //*************************************************************** void GradeBook::Start_Up_Screen(int X, int Y) { clrscr(); textbackground(BLACK); textcolor(GREEN); //How far the Block will go across for(int I = 0; I < X; I++) cout<<"²"; //alt 178 cout<> "; cin>>Choice; }//End while Loop while( (Choice < 0) || (Choice > 4) ); //What will happen from whatever the users choice was switch(Choice) { case 1: New_GradeBook(); break; case 2: Load_GradeBook(); break; case 3: About_GradeBook(); break; case 4: do { //Prompt the user to make sure he wants to exit Start_Up_Screen(79,23); gotoxy(11,7); cout<<"Are you sure you want to exit the gradebook (y/n) >> "; cin>>Char_Choice; }//end while loop while( (Char_Choice != 'Y') && (Char_Choice != 'y') && (Char_Choice != 'N') && (Char_Choice != 'n')); //Check what they typed in if( (Char_Choice == 'Y') || Char_Choice == 'y') exit(1); else { Teacher_Name = NULL;//Make the string equal nothing again View_Intructions(2,"Hargraves");//Do recursion to see the //instructions again } break; }//end case } void GradeBook::New_GradeBook() { int IndexNum = 0;//This will hold the total amount of room allocated for all int GradesNum = 0;//This will hold the total amount of room allocated for daily int TestNum = 0;//This will hold the total amount of room allocated for test char* FileExten = "C:\\"; char SaveName[255]; char *Temp = NULL; char Pick;// This will let the the gradebook knows if this is password protected double Percentage[2];//This will hold the weight of the test and daily grades Percentage[0] = 0.0; Percentage[1] = 0.0; Percentage[2] = 0.0; Student_Info *Info; //Number of student this will allocate the right room for each Start_Up_Screen(79,23); gotoxy(11,7); cout<<"Enter the number of students in your class>> "; cin>>IndexNum; Info = new Student_Info[IndexNum]; //This will allocate the appropiate //space for the structs //Number grades per student this will allocate the right room for each Start_Up_Screen(79,23); gotoxy(11,7); //Set all the allocations for the test Grades member in Student_Info cout<<"Enter the number of grades for each student>> "; cin>>TestNum; for(int I = 0; I < IndexNum; I++) Info[I].Test = new double[TestNum]; //Set all the allocations for the daily Grades member in Student_Info gotoxy(11,8); cout<<"Enter the number of grades for each student>> "; cin>>GradesNum; for(I = 0; I < IndexNum; I++) Info[I].Grades = new double[GradesNum]; Start_Up_Screen(79,23); gotoxy(11,8); cout<<""; gotoxy(13,9); cout<<"File Size: "<> "; cin>>Info[I].StudentID; //Enter in Student First Name Start_Up_Screen(79,23); gotoxy(11,8); cout<<"Enter in students First Name>> "; cin>>Info[I].First; //Enter in Student Last Name Start_Up_Screen(79,23); gotoxy(11,8); cout<<"Enter in students Last Name>> "; cin>>Info[I].Last; //Enter in Student First Name Start_Up_Screen(79,23); gotoxy(11,8); cout<<"Enter in student Grade Level>> "; cin>>Info[I].GradeLevel; //Nested loop to get the amount of test grades for(int J = 0; J < TestNum; J++) { //Enter in Student test grades Start_Up_Screen(79,23); gotoxy(11,8); cout<<"Enter in students"<<" "<<"test grades"<> "; cin>>Info[I].Test[J]; }//end nested loop //Nested loop to get the amount of daily grades for(J = 0; J < GradesNum; J++) { //Enter in Student daily grades Start_Up_Screen(79,23); gotoxy(11,8); cout<<"Enter in students"<<" "<<"Grade"<> "; cin>>Info[I].Grades[J]; }//end nested loop }//end outer loop //******************************************************************* //Retrieve the the weight for the daily grades as well as test grades //******************************************************************* Start_Up_Screen(79,23); gotoxy(11,6); cout<<"Enter in the weight for test grades>> "; cin>>Percentage[0]; gotoxy(11,7); cout<<"Enter in the weight for daily grades>> "; cin>>Percentage[1]; //*********************************************************************** //This part will prompt the user if he/she wants a password protected file //*********************************************************************** Start_Up_Screen(79,23); gotoxy(11,6); cout<<"Max of 10 chars"; gotoxy(11,7); cout<<"Will this file be password protected (y/n)>> "; cin>>Pick; if(Pick == 'Y' || Pick == 'y') { Info[0].PwdCheck = 1;//Let the file know of there is a password cout<<"Enter the password: "; cin>>Info[0].Password; }//end if if(Pick == 'N' || Pick == 'n') Info[0].PwdCheck = 0;//Let the file know of there is a password //************************************************************************ //***************************************************************** //For optimization lets create the save part inside new gradebook //******************************************************************* Start_Up_Screen(79,23); gotoxy(11,7); cout<<"Type only the file name (e.g. Test)"; gotoxy(11,8); cout<<" Enter the name of the file>> "; cin>>SaveName; //Concatinate the strings strcat(FileExten,SaveName);//Concatinate filename strcpy(Temp,FileExten);//Put the EX:(C:\\Test)into Temp strcat(FileExten,".txt");//concatinate the extention .txt //Save the data to a file ofstream FileS2(FileExten); FileS2<> "; cin>>LoadName; strcat(FileExten,LoadName); strcat(FileExten,".txt"); cout<>IndexNum;//Load how much is suppost to allocated FileL2>>TestNum;//Load the amount of grades per student FileL2>>GradesNum;//Load the amount of grades per student FileL2>>PwdCheck; FileL2>>FilePas; Student_Info *Info = new Student_Info[IndexNum];//Allocate the correct //room for the student //Allocate the right amount of room for the test grades for(int I = 0; I < TestNum; I++) Info[I].Test = new double[TestNum]; //Allocate the right amount of room for the daily grades for(I = 0; I < GradesNum; I++) Info[I].Grades = new double[GradesNum]; //************************* //Check for the password //************************* if(PwdCheck == 1) { Start_Up_Screen(79,23); gotoxy(11,7); cout<<"Enter in the password>> "; cin>>Password; if(strcmpi(Password,FilePas) == 0) {//Begin inner if Start_Up_Screen(79,23); gotoxy(11,7); cout<<"Correct, Press any key to view data"; //Clear all data strcpy(Password,"");//Put nothing in Password strcpy(LoadName,"");//Put nothing in LoadName strcpy(FileExten,"C:\\");//Put nothing in Password getch(); }//End inner if else//If the password is not right return to the menu {//Begin else Start_Up_Screen(79,23); gotoxy(11,7); cout<<"Incorrect, Access Denied!"; //Clear all data strcpy(Password,"");//Put nothing in Password strcpy(LoadName,"");//Put nothing in LoadName strcpy(FileExten,"C:\\");//Put nothing in Password getch(); Start_Up_Screen(79,23); View_Intructions(2,""); }//End Else }//Enter outer If //Load the weight FileL2>>Percentage[0]; FileL2>>Percentage[1]; //Load all data into the structs for(int A = 0; A < IndexNum;A++) { FileL2>>Info[A].StudentID; FileL2>>Info[A].First; FileL2>>Info[A].Last; FileL2>>Info[A].GradeLevel; for(int B = 0; B < TestNum; B++) FileL2>>Info[A].Test[B]; for(B = 0; B < GradesNum; B++) FileL2>>Info[A].Grades[B]; }//End For Loop clrscr(); for(A = 0; A < IndexNum;A++) { Start_Up_Screen(79,23); gotoxy(11,7); cout<<"Student #"<= 60)//Control Range { RangeX = 11; RangeY++; gotoxy(RangeX,RangeY);//Goto to that direct cursor location } else { cout<<"|"<= 60)//Control Range { RangeX = 11; RangeY++; gotoxy(RangeX,RangeY);//Goto to that direct cursor location } else { cout<<"|"<>"; gotoxy(13,12); cout<<"<>"; gotoxy(13,13); cout<<"<>"; getch(); Start_Up_Screen(79,23);//Create the simple interface View_Intructions(2,""); }