//Student: Luis Echegaray #include #include #include #include #include #include #include #include #include #include #include #include #include void quit(); void menu(); void intro(); void one(); void two(); void three(); void four(); void subone(); void subtwo(); void subthree(); void error(); void opernum1(); void opernum2(); void opernum3(); void opernum4(); //***********************Variable Declarations******************************* float subtfrom,subt,subans, sortchoice; float counter1,cal2; float cal1; float end,temp,sum1,thing[10],multi1,numsort; int choicethree,opernum; int driver=VGA; int mode=VGAHI,x,y,a,r; int choice,total,answers[20],highscore[20], draw, draws; char quizchoice[20], menuchoice1[20]; char ansquiz[10][80],tfquiz[5][5]; int answer; char planet[10] [30], temp1[10]; int multiplechoice,fillintheblankchoice,tfchoice,quizaverage,rawscore; //******************************Program************************************** void main() { clrscr(); intro(); menu(); getch(); } void intro() { initgraph(&driver,&mode,"\\TC\\BGI"); setcolor(3); settextstyle(10,0,2); delay(1000); outtextxy(80,75,"WELCOME TO MY PROGRAM"); getch(); for (x=0;x<=800;x++) { setcolor(RED); circle(x,100,50); } setcolor(4); settextstyle(7,0,2); delay(1000); outtextxy(30,180,"THIS WILL BE THE MOST FUN YOU EVER HAD!!"); getch(); for (x=800;x>=0;x--) { setcolor(WHITE); circle(x,200,50); } setcolor(CYAN); settextstyle(8,0,3); delay(1000); outtextxy(30,260,"WELL NOT REALLY...THIS IS MY C++ FINAL."); outtextxy(30,290,"PLEASE BEAR WITH ME...... "); getch(); for (x=0;x<=800;x++) { setcolor(BLUE); circle(x,300,50); } setcolor(RED); outtextxy(140,170,"Press Any Key to Continue"); getch(); closegraph(); } //**************************************************************************** void menu() { cout<<"Welcome to My Program Menu\n"; cout<<"Choose a number.... \n"; cout<<"(1) Quiz\n"; cout<<"(2) Collection of Graphics\n"; cout<<"(3) Answer Key\n"; cout<<"(4) Quit\n"; cin>>choice; switch (choice) { case 1:{one();break;} case 2:{two();break;} case 3:{three();break;} case 4:{quit();break;} default: printf("PLEASE ENTER A VALID SELECTION"); delay(1500); clrscr(); menu(); } } //*************************************************************************** void one() { if (choice==1) { clrscr(); cout<<"Please answer all question with lower case letters or words please\n"; clrscr(); cout<<"Ok then in.....\n5\n"; delay(500); cout<<"4\n"; delay(500); cout<<"3\n"; delay(500); cout<<"2\n"; delay(500); cout<<"1\n"; delay(500); clrscr(); cout<<"This is the multiple choice section of this quiz..\n"; cout<<"The question are of random subjects..\n"; cout<<"press any key to continue..\n"; getch(); clrscr(); initgraph(&driver,&mode,"\\TC\\BGI"); setcolor(RED); setbkcolor(LIGHTGREEN); delay(1500); setbkcolor(BLACK); line(120,90,120,340);//Border line(120,340,520,340); line(520,340,520,90); line(520,90,120,90); setcolor(BLUE); line(140,110,140,320);//inner border line(140,320,500,320); line(500,320,500,110); line(500,110,140,110); setcolor(CYAN); line(170,370,170,430);//lower box line(170,430,470,430); line(470,430,470,370); line(470,370,170,370); setcolor(LIGHTMAGENTA); line(30,90,70,130);//x1 delay(100); line(70,130,30,170); delay(100); line(30,170,70,210); delay(100); line(70,210,30,250); delay(100); line(30,250,70,290); delay(100); line(70,290,30,330); delay(100); line(70,90,30,130);//x2 delay(100); line(30,130,70,170); delay(100); line(70,170,30,210); delay(100); line(30,210,70,250); delay(100); line(70,250,30,290); delay(100); line(30,290,70,330); delay(100); setcolor(CYAN); line(570,90,610,130);//y1 delay(100); line(610,130,570,170); delay(100); line(570,170,610,210); delay(100); line(610,210,570,250); delay(100); line(570,250,610,290); delay(100); line(610,290,570,330); delay(100); line(610,90,570,130);//y2 delay(100); line(570,130,610,170); delay(100); line(610,170,570,210); delay(100); line(570,210,610,250); delay(100); line(610,250,570,290); delay(100); line(570,290,610,330); settextstyle(6,0,3); setcolor(YELLOW); outtextxy(14,1,"Question"); outtextxy(450,1,"Category:"); gotoxy(57,4); cout<<"Multiple Choice"; settextstyle(1,0,2); outtextxy(30,360,"Correct"); outtextxy(520,360,"Incorrect"); total=0; gotoxy(7,3); cout<<"1"; x=0; while(x!=1) { gotoxy(27,11); cout<<"Who was the 16th president? "<>answers[1]; if (answers[1]==1) { x=1; total=1; settextstyle(9,0,3); outtextxy(245,380,"Correct!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); setfillstyle(0,1); floodfill(300,200,1); } else if (answers[1]==2 || answers[1]==3) { x=1; settextstyle(9,0,3); outtextxy(240,380,"Incorrect!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); } else { gotoxy(25,18); cout<<"ERROR: Please enter valid selection"; delay(1500); setfillstyle(0,1); floodfill(300,200,1); } } setfillstyle(0,1); floodfill(300,200,1); x=0; while(x!=1) { gotoxy(7,3); cout<<"2"; gotoxy(27,11); cout<<"What is the square root of 36? "<>answers[2]; if (answers[2]==2) { x=1; total=total+1; setfillstyle(0,1); outtextxy(245,380,"Correct!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); setfillstyle(0,1); floodfill(300,200,1); } else if (answers[2]==1 || answers[2]==3) { x=1; settextstyle(9,0,3); outtextxy(240,380,"Incorrect!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); } else { gotoxy(25,18); cout<<"ERROR: Please enter valid selection"; delay(1500); setfillstyle(0,1); floodfill(300,200,1); } } setfillstyle(0,1); floodfill(300,200,1); x=0; while(x!=1) { gotoxy(7,3); cout<<"3"; gotoxy(21,11); cout<<"Which one of these is a New York burrow? "<>answers[3]; if (answers[3]==3) { x=1; total=total+1; settextstyle(9,0,3); outtextxy(245,380,"Correct!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); setfillstyle(0,1); floodfill(300,200,1); } else if (answers[3]==1 || answers[3]==2) { x=1; settextstyle(9,0,3); outtextxy(240,380,"Incorrect!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); } else { gotoxy(25,18); cout<<"ERROR: Please enter valid selection"; delay(1500); setfillstyle(0,1); floodfill(300,200,1); } } setfillstyle(0,1); floodfill(300,200,1); x=0; gotoxy(7,3); cout<<"3"; while(x!=1) { gotoxy(22,11); cout<<"Which of the following is a true color? "<>answers[4]; if (answers[4]==2) { x=1; total=total+1; settextstyle(9,0,3); outtextxy(245,380,"Correct!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); setfillstyle(0,1); floodfill(300,200,1); } else if (answers[4]==1 || answers[4]==3) { x=1; settextstyle(9,0,3); outtextxy(240,380,"Incorrect!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); } else { gotoxy(25,18); cout<<"ERROR: Please enter valid selection"; delay(1500); setfillstyle(0,1); floodfill(300,200,1); } } setfillstyle(0,1); floodfill(300,200,1); x=0; while(x!=1) { gotoxy(7,3); cout<<"5"; gotoxy(21,11); cout<<"What is the name of a person who studies\n"; gotoxy(21,12); cout<<"artifacts? "<>answers[5]; if (answers[5]==3) { x=1; total=total+1; settextstyle(9,0,3); outtextxy(245,380,"Correct!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); setfillstyle(0,1); floodfill(300,200,1); } else if (answers[5]==1 || answers[5]==2) { x=1; settextstyle(9,0,3); outtextxy(240,380,"Incorrect!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); } else { gotoxy(25,18); cout<<"ERROR: Please enter valid selection"; delay(1500); setfillstyle(0,1); floodfill(300,200,1); } } closegraph(); ofstream thefile; thefile.open ("a:a1.txt",ios::out); //if adding to end of file use ios::app for(x=0; x<=4; x++) thefile<>tfquiz[1]; if (strcmp(tfquiz[1],"t")==0) { x=1; total=1; settextstyle(9,0,3); outtextxy(245,380,"Correct!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); setfillstyle(0,1); floodfill(300,200,1); } else if (strcmp(tfquiz[1],"f")==0) { x=1; settextstyle(9,0,3); outtextxy(240,380,"Incorrect!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); } else { gotoxy(25,18); cout<<"ERROR: Please enter valid selection"; delay(1500); setfillstyle(0,1); floodfill(300,200,1); } } setfillstyle(0,1); floodfill(300,200,1); x=0; while(x!=1) { gotoxy(7,3); cout<<"12"; gotoxy(22,11); cout<<" 4*8(12/3)-5=4 "<>tfquiz[2]; if (strcmp(tfquiz[2],"f")==0) { x=1; total=total+1; settextstyle(9,0,3); outtextxy(245,380,"Correct!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); setfillstyle(0,1); floodfill(300,200,1); } else if (strcmp(tfquiz[2],"t")==0) { x=1; settextstyle(9,0,3); outtextxy(240,380,"Incorrect!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); } else { gotoxy(25,18); cout<<"ERROR: Please enter valid selection"; delay(1500); setfillstyle(0,1); floodfill(300,200,1); } } setfillstyle(0,1); floodfill(300,200,1); gotoxy(7,3); cout<<"13"; x=0; while(x!=1) { gotoxy(22,11); cout<<"A nonagon has 7 sides "<>tfquiz[3]; if (strcmp(tfquiz[3],"f")==0) { x=1; total=total+1; settextstyle(9,0,3); outtextxy(245,380,"Correct!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); setfillstyle(0,1); floodfill(300,200,1); } else if (strcmp(tfquiz[3],"t")==0) { x=1; settextstyle(9,0,3); outtextxy(240,380,"Incorrect!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); } else { gotoxy(25,18); cout<<"ERROR: Please enter valid selection"; delay(1500); setfillstyle(0,1); floodfill(300,200,1); } } setfillstyle(0,1); floodfill(300,200,1); gotoxy(7,3); cout<<"14"; x=0; while(x!=1) { gotoxy(22,11); cout<<"When the word product is used\n"; gotoxy(22,12); cout<<"it means division"<>tfquiz[4]; if (strcmp(tfquiz[4],"f")==0) { x=1; total=total+1; settextstyle(9,0,3); outtextxy(245,380,"Correct!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); setfillstyle(0,1); floodfill(300,200,1); } else if (strcmp(tfquiz[4],"t")==0) { x=1; settextstyle(9,0,3); outtextxy(240,380,"Incorrect!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); } else { gotoxy(25,18); cout<<"ERROR: Please enter valid selection"; delay(1500); setfillstyle(0,1); floodfill(300,200,1); } } setfillstyle(0,1); floodfill(300,200,1); gotoxy(7,3); cout<<"15"; x=0; while(x!=1) { gotoxy(22,11); cout<<"The pythagorean theorem is used\n"; gotoxy(22,12); cout<<"mainly with right triangles "<>tfquiz[5]; if (strcmp(tfquiz[5],"t")==0) { x=1; total=total+1; settextstyle(9,0,3); outtextxy(245,380,"Correct!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); setfillstyle(0,1); floodfill(300,200,1); } else if (strcmp(tfquiz[5],"f")==0) { x=1; settextstyle(9,0,3); outtextxy(240,380,"Incorrect!!"); delay(1500); setfillstyle(0,1); floodfill(300,400,3); } else { gotoxy(25,18); cout<<"ERROR: Please enter valid selection"; delay(1500); setfillstyle(0,1); floodfill(300,200,1); } } setfillstyle(0,1); floodfill(300,200,1); closegraph(); ofstream thefile3; thefile3.open ("a:a3.txt",ios::out); //if adding to end of file use ios::app for(x=1; x<=5; x++) thefile3<=94) { gotoxy(1,18); cout<<"You got an A!!!\n"; } if (quizaverage<=93 && quizaverage>85) { gotoxy(1,18); cout<<"You got a B!\n"; } if (quizaverage<=84 && quizaverage>76) { gotoxy(1,18); cout<<"You got a C\n"; } if (quizaverage<=75 && quizaverage>69) { gotoxy(1,18); cout<<"You got a D\n"; } if (quizaverage<69) { gotoxy(1,18); cout<<"You got a F!\n"; cout<<"BOOOOOOOO\n"; } getch(); gotoxy(20,1); clrscr(); cout<<"Do you wish to go back to the menu(y/n)?\n"; cin>>menuchoice1; if (strcmp(menuchoice1,"y")==0) { clrscr(); menu(); } if (strcmp(menuchoice1,"n")==0) { cout<<"Goodbye then...\n"; delay(1000); cout<<"Press any key to shutdown this program....\n"; } } //*************************************************************************** void two() { if (choice==2) { cout<<"You have selected option #2!!\n"; cout<<"Press any key to continue...\n"; getch(); initgraph(&driver,&mode,"\\TC\\BGI"); for(a=0;a<=800;a++) { setcolor(GREEN); line(0,0,sin(a)*400,cos(a)*400); delay(400/(a+10)); setcolor(0); line(50,50,sin(a)*400,cos(a)*400); } setcolor(YELLOW); settextstyle(2,0,5); delay(1000); outtextxy(240,375,"What does this look like?"); outtextxy(245,400,"Use your imagination."); delay(1500); outtextxy(260,450,"Press any key to continue..\n"); getch(); closegraph(); initgraph(&driver,&mode,"\\TC\\BGI"); settextstyle(9,0,2); outtextxy(70,150,"Now For a Colorful Experience!"); settextstyle(8,0,3); setcolor(YELLOW); outtextxy(140,200,"WARNING: INTENSE COLORS"); setcolor(RED); outtextxy(140,240,"Dont Forget Colorful..."); delay(2000); setcolor(BLACK); settextstyle(9,0,2); outtextxy(70,150,"Now For a Colorful Experience!"); settextstyle(8,0,3); outtextxy(140,200,"WARNING: INTENSE COLORS"); outtextxy(140,240,"Dont Forget Colorful..."); delay(1500); for(a=600;a>=0;a--) { setcolor(RED); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(5); } for(a=0;a<=600;a++) { setcolor(BLUE); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } for(a=600;a>=0;a--) { setcolor(GREEN); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } for(a=0;a<=600;a++) { setcolor(YELLOW); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } for(a=600;a>=0;a--) { setcolor(LIGHTMAGENTA); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } for(a=0;a<=600;a++) { setcolor(CYAN); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } for(a=600;a>=0;a--) { setcolor(LIGHTGRAY); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } for(a=0;a<=600;a++) { setcolor(LIGHTBLUE); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } for(a=600;a>=0;a--) { setcolor(LIGHTCYAN); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } for(a=0;a<=600;a++) { setcolor(LIGHTRED); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } for(a=600;a>=0;a--) { setcolor(MAGENTA); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } for(a=0;a<=600;a++) { setcolor(WHITE); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } for(a=600;a>=0;a--) { setcolor(BLACK); line(320,0+a,320+a,480*sin(a)); line(320,0+a,320-a,480*sin(a)); delay(0); } setcolor(GREEN); settextstyle(6,0,7); outtextxy(100,100,"Pretty Colorful Eh?"); delay(2000); getch(); closegraph(); int cont; clrscr(); initgraph(&driver,&mode,"\\TC\\BGI"); for (x=1;x<=140;x++) { setcolor(RED); circle(320,240,75+x*cos(x)); delay(15); } for(a=0;a<=400;a++) { setcolor(WHITE); line(320,0+a,320+a,80*sin(a)); setcolor(YELLOW); line(320,0+a,320-a,80*sin(a)); delay(10); } for (x=1;x<=60;x++) { setcolor(GREEN); circle(150,150,65+x*cos(x)); delay(15); } for (x=1;x<=60;x++) { setcolor(CYAN); circle(500,150,65+x*cos(x)); delay(15); } for (x=1;x<=60;x++) { setcolor(MAGENTA); circle(150,350,65+x*cos(x)); delay(15); } for (x=1;x<=60;x++) { setcolor(YELLOW); circle(500,350,65+x*cos(x)); delay(15); } delay(1500); getch(); closegraph(); clrscr(); cout<<"Do you wish to go back to the menu(y/n)?\n"; cin>>menuchoice1; if (strcmp(menuchoice1,"y")==0) { clrscr(); menu(); } if (strcmp(menuchoice1,"n")==0) { cout<<"Goodbye then...\n"; delay(1000); cout<<"Press any key to shutdown this program....\n"; } } } //*************************************************************************** void three() { clrscr(); int answer[20][20]; int mc[20][20]; char tf[10][20]; char fb[10][20]; ifstream key; key.open ("a:key.txt",ios::in); x=0; while (!key.eof()) { key>>fb[x]>>"\n"; x++; } clrscr(); cout<<"Multiple Choice Section:\n"; cout<<"1\n2\n3\n2\n3\n"; cout<<"\n"; cout<<"Fill in the Blank Section\n"; for (x=0; x<=4; x++) { cout<>menuchoice1; if (strcmp(menuchoice1,"y")==0) { clrscr(); menu(); } if (strcmp(menuchoice1,"n")==0) { cout<<"Goodbye then...\n"; delay(1000); cout<<"Press any key to shutdown this program....\n"; getch(); } } void quit() { clrscr(); initgraph(&driver,&mode,"\\TC\\BGI"); settextstyle(8,0,4); outtextxy(150,100,"QUITING ALREADY??"); outtextxy(260,140,"O.K."); outtextxy(220,180,"BYE BYE"); delay(3000); closegraph(); } //****************************************************************************