From b92030e73b52adb567ce1d0376dfa0079611ab65 Mon Sep 17 00:00:00 2001 From: fdlt3885 Date: Wed, 8 Feb 2023 17:52:32 +0000 Subject: [PATCH] Added a Geography Quiz Game --- src/main/quizproject.c | 53 +++++++++++++++++++++++++++++++++++++++++- src/main/quizproject.h | 6 +++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/main/quizproject.c b/src/main/quizproject.c index e851401..a50288f 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -2110,6 +2110,52 @@ void b_epic_game() { B_write_review(); } + +//geography quiz// + +void b_WelcomeMessage() { + printf("Welcome to the geography quiz game!\n"); + printf("Let's test your knowledge of geography!\n"); +} + +int b_askQuestion(int questionNumber, char* question, char* answer) { + char userAnswer[100]; + printf("Question %d: %s\n", questionNumber, question); + printf("Your answer: "); + scanf("%s", userAnswer); + return strcmp(userAnswer, answer) == 0; +} + +void b_displayResults(int correctAnswers) { + printf("You got %d out of 10 questions correct.\n", correctAnswers); + if (correctAnswers >= 8) { + printf("Excellent performance! You are a geography master!\n"); + } else if (correctAnswers >= 5) { + printf("Good job! You know a fair bit about geography!\n"); + } else { + printf("You need to brush up on your geography. Keep trying!\n"); + } +} + + +void b_play_geography(){ + int correctAnswers = 0; + b_WelcomeMessage(); + correctAnswers += b_askQuestion(1, "What is the capital of France?", "Paris"); + correctAnswers += b_askQuestion(2, "What is the largest ocean in the world?", "Pacific"); + correctAnswers += b_askQuestion(3, "What is the currency of Japan?", "Yen"); + correctAnswers += b_askQuestion(4, "What is the tallest mountain in the world?", "Everest"); + correctAnswers += b_askQuestion(5, "What is the longest river in Africa?", "Nile"); + correctAnswers += b_askQuestion(6, "What is the capital of China?", "Beijing"); + correctAnswers += b_askQuestion(7, "What is the currency of the European Union?", "Euro"); + correctAnswers += b_askQuestion(8, "What is the capital of Australia?", "Canberra"); + correctAnswers += b_askQuestion(9, "What is the largest desert in the world?", "Sahara"); + correctAnswers += b_askQuestion(10, "What is the capital of India?", "New Delhi"); + b_displayResults(correctAnswers); +} + + + void v_play_rockpapersciss(){ int player_choice, computer_choice, player_score = 0, computer_score = 0; srand(time(NULL)); @@ -2580,7 +2626,8 @@ int main(int argc, char *argv[]) { printf("8. Rock,Paper,Scissors!\n"); printf("9. Math Quiz\n"); printf("10. Check your Horoscope!\n"); - printf("11. Exit\n"); + printf("11. Play Geography Quiz!\n"); + printf("12. Exit\n"); printf("Enter your choice: "); scanf("%d", &choice); v_progress_bar(argc,argv); @@ -2627,6 +2674,10 @@ int main(int argc, char *argv[]) { jump_to_menu = 1; break; case 11: + b_play_geography(); + jump_to_menu = 1; + break; + case 12: printf("\nThank you for trying our C code!\n"); break; default: diff --git a/src/main/quizproject.h b/src/main/quizproject.h index e8b18d3..c0c2b33 100644 --- a/src/main/quizproject.h +++ b/src/main/quizproject.h @@ -95,6 +95,12 @@ void B_saythankyou(void); void rate(void); void B_write_review(void); +//Geography quiz headers +void b_WelcomeMessage(); +int b_askQuestion(int questionNumber, char* question, char* answer); +void b_displayResults(int correctAnswers); +void b_play_geography(); + #define NUM_QUESTIONS 5 #define NUM_ROUNDS 15