Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions AvaFinalProject.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Ava N.
July 9, 2016

Final Project Proposal:

For my final project, I would like to create a quiz show, similar to Jeopardy. The objective of the game is to answer as many questions correctly as possible. I will be adding a time limit as well.

The questions would be divided into different categories. For example, under the "computer science" category, the lowest, or '100' slot question might state: 'This device was used to solve math problems before the invention of electricity." The answer, which would not be case sensitive, would be inputed by the contestant/player. Also, I am deciding whether to require the player input to include "what is ..." before the answer. This game will be created for a single-player, but if I have time, I would like to make a 2, 3, or 4 player option as well.

An example of a loop I would use is for the fill-in the answer section. If the correct answer is chosen, then the point goes to the player who asked the question (under a time limit). If that person does not answer correctly or under the time limit, it will go to the next player, and if that player answers correctly, then the original amount of points will get split in half. I will also use functions for the input of the contestant.

I am choosing this project because taking part in a quiz show or game is so much fun, and playing one that I create would be great. I am excited to develop the game design and decide how I will arrange the 'answers' and the 'questions', and where I will put the timer, and arrange different color schemes.

Libraries I will use are the include the ones we have used in class: stdio.h, string.h, math.h, etc. I plan to use the time.h library for the timer. For graphics, I may want to use Cairo, although I have never used that library before.

This is my Final Project Proposal and I am excited to start working on it (once it is approved)!
30 changes: 30 additions & 0 deletions FinalProject/answer.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Army
Switzerland
Hyena
New York City
Mudd
Winter
700
February
Bonjour
Whale
1492
Abacus
Orange
P
Hydrogen
24
Nile River
Mount Everest
Elvis Presley
Damascus
Sicily
Venezuela
Retriever
1984
Theodore Roosevelt
6
1509
Queue
Ada Lovelace
Yes
1 change: 1 addition & 0 deletions FinalProject/extra.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

30 changes: 30 additions & 0 deletions FinalProject/questions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
1. What is a group of frogs known as?
2. What country has the highest environmental performance index?
3. Which animal laughs like human being?
4. In which city is manhattan located?
5. In which building is the Columbia HSP for Intro to Programming in C?
6. During what season do animals hybernate?
7. How much wood would a woodchuck chuck if a woodchuck could chuck wood (answer in pounds)?
8. In what month is Valentine's Day?
9. How do you say 'Hello/Good morning' in french?
10. Which underwater creature is bigger: Dolphin or Whale?
11. In what year did Christopher Columbus sail the ocean blue?
12. What device was used to solve math problems before the invention of electricity?
13. What color comes after red in the rainbow?
14. What is the 16th letter in the alphabet?
15. What is the first element in the periodic table (not in scientific notation)?
16. How many students are in the Introduction to Programming in C class?
17. What is the longest river in the world? (include 'River' at the end of answer)
18. What is the highest mountain in the world?
19. Who is known for being the King of Rock 'n Roll?
20. What is the world's oldest city?
21. What is the largest island in the Mediterranean sea?
22. In what country is the highest waterfall in the world?
23. What is the most popoular breed of dog?
24. In which year was the first computer sold with a mouse?
25. Who was the youngest President in the United States?
26. How many legs do butterflies have?
27. In which year did Henry VIII become King of England?
28. What is a linear data structure in which elements are added on one end and removed from the other?
29. Which female mathematician developed the first algorithm for the Analytical Machine?
30. Did you enjoy playing? (Yes/No)
Binary file added FinalProject/quiz_game
Binary file not shown.
170 changes: 170 additions & 0 deletions FinalProject/quiz_game.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
//Ava N.'s

//REAL VERSION -- Ava's Quiz Show
//Columbia HSP FInal Project
//Intro to Programming in C
//Due: July 15, 2016

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>


void help(){ //gives instructions of the game
system("clear");
printf("\n\n Instructions:");
printf("\n ------------------------------------------------------");
printf("\n ................... Ava's Quiz Show ....................");
printf("\n >> You have to be able to answer 30 questions correctly.");
printf("\n >> All of the questions require fill-in answers.");
printf("\n >> This game is case-sensitive, so all answers have to");
printf("\n have the first letter of each word uppercase.");
printf("\n >> If the question asks for a number, answer with a number.");
printf("\n >> The maximum number of points a you can get is 11.");

printf("\n >> You will not be penalized for incorrect answers.");

printf("\n\n\t**************Good Luck*******************\n\n");
printf("\n\n\t Press 'enter' to continue to the main menu\n");
}



//start of the game show
int main(void){

system("clear");
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[100]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i; //variable for loop that checks contestants answers
int e; //variable for going through the questions.txt file
const int num_ques=29; //includes number of questions
char choice; //main menu variable
int countr = 0; //score

mainhome:
system("clear"); //source: http://stackoverflow.com/questions/15102976/how-to-clear-screen-from-simple-c-program
//printf("\t\t\tC PROGRAM QUIZ GAME\n");
printf("\n\t\t________________________________________");

printf("\n\t\t\t * WELCOME *");
printf("\n\t\t\t * to *");
printf("\n\t\t\t * AVA'S GAME SHOW *");
printf("\n\t\t ____*_*_*_*_*_*_*_*_*_*_*_*____");
printf("\n\t\t________________________________________");
printf("\n\t\t\t BECOME THE CHAMPION!!! ") ;
printf("\n\t\t________________________________________");
printf("\n\t\t________________________________________");
printf("\n\t\t > Press S to start the game");
printf("\n\t\t > press H for help ");
printf("\n\t\t > press Q to quit ");
printf("\n\t\t________________________________________\n\n");


printf("\n\n\tAnswers must all begin with an uppercase letter\n\n\n");
//MAIN MENU SELECTION OPTIONS
choice=toupper(getchar());
printf("you entered %c\n",choice);

if (toupper(getchar())=='S')
goto home;
else if (choice=='H'){
printf("you typed in H");
help();
getchar();
goto mainhome;
}
else if (choice=='Q'){
printf("you typed in Q");
exit(1);

}


home:
//HAVING QUESTIONS PRINT ONE AT A TIME
for (e=0; e < num_ques; e++) //loop to go through each question in text file
{
//printf("\nQuestion:");
printf("\n***Type in your answer to the following question:\n\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL)
{
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c

if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL)
{
fprintf(stderr,"Error while reading file\n");
return -1;
}



for (i=0; i < 1; i++)
{
// printf("%d\n",i);
//fprintf(stderr,"DIAGNOSTIC -- the answer: %s\n", ans_arr);
//printf("DIAGNOSTIC -- GUESS variable is:%s\n", guess);
fgets(guess, sizeof(guess), stdin);

//fprintf(stderr,"you answered %s\n",guess);

if (strcmp(ans_arr, guess) == 0)
{
printf("Your guess was correct\n\n");
countr++;
}
else if (guess!=ans_arr)
{
printf("Your guess was incorrect.\n");
printf("The answer was: %s\n\n\n\n", ans_arr);
}
else
{
printf("You ran out of questions.");
}
}
}


fclose(questions);
fclose(answers);

//SHOWING THE CONTESTANT THEIR SCORE - HOW MANY QUESTIONS THEY GOT CORRECT
score:
system("clear");
//score=countr;
//printf("* DIAGNOSTIC -- countr is %d\n",countr);
//printf("* DIAGNOSTIC -- score is %d\n",score);
if(countr>0 && countr<=29){
printf("\n\n\t\t************* CONGRATULATIONS **************");
printf("\n\t\t\t You won %d points! \n", countr);
}

else if(countr==30){ //highest score possible
printf("\n\n\n \t\t*********** Nice Job!! ***********");
printf("\n\t\t\t\t You are the champion!!!!!!!!!");
printf("\n\t\t\t You won %d points! \n",countr);
printf("\t\t Thank You!!");
}
else{
printf("\n\n\t******** You did not win any points ********");
printf("\n\t\t Thanks for playing!. \n");
printf("\n\t\t Better luck next time! \n");
}



return 0;


}
30 changes: 30 additions & 0 deletions FinalProject/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Ava N.
July 15, 2016
Ava's Quiz Game

This is a quiz show game programmed in C during Columbia HSP. My project takes questions from 'questions.txt' and answers from 'answer.txt' to these questions. There is a 'help' center, a 'quit' command, and a command to start the game. All instructions of how to play the game are inside of the game. This is a one player game.


In my proposal, I mentioned including a timer; however, I decided in the end not to add one. I also stated in my introduction that I would have different slots for different categories with different point systems. I later decided that I would not have different categories but a list of questions that players of 'Ava's Quiz Game' would need to answer. Although I did not have time to include graphics, I created a fun looking 'main menu'!

All of the answers to the questions, if you want to beat the game, are in answer.txt .


I got my idea of how to set up Ava's Quiz Show here: http://www.codewithc.com/quiz-game-mini-project-in-c/



Files used in Ava's Quiz Show: [quiz_game.c], [questions.txt], and [answers.txt]. All other files in Final Code folder were used to test the code in the main file.


I hope you enjoy Ava's Quiz Show!



compile statement:
gcc quiz_game.c -o quiz_game
./quiz_game




Binary file added FinalProject/sam
Binary file not shown.
59 changes: 59 additions & 0 deletions FinalProject/sample_doc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//This is for checking the code of the question-answer section in quiz_game code

#include <stdio.h>
#include <string.h>

int main (void){
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[25]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i;
int e;
const int num_ques=5;
for (e=0; e < num_ques; e++){

printf("Type in your answer to the following question:\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL){ //read 1 line from file
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c
if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL){
fprintf(stderr,"Error while reading file\n");
return -1;
}

for (i=0; i < 1; i++){ //Loop for questions asking
//printf("%d\n",i);
//fprintf(stderr,"the answer: %s\n", ans_arr);
//printf("Please guess the word: \n");
fgets(guess, sizeof(guess), stdin);

fprintf(stderr,"you answered %s\n",guess);
if (strcmp(ans_arr, guess) == 0){
printf("Your guess was correct\n\n");
//continue;
}
else if (guess!=ans_arr){
printf("Your guess was incorrect.\n\n\n");
//continue;
}
else {
printf("You ran out of questions");
//break;
}
}
}


fclose(questions);
fclose(answers);
return 0;
}


Binary file added FinalProject/temp
Binary file not shown.
Loading