From 6d5ba78c52f746d0f12372a155a1e9546c3cc47a Mon Sep 17 00:00:00 2001 From: fdlt3859 Date: Thu, 9 Feb 2023 01:03:30 +0000 Subject: [PATCH] Added Replay option (v_AllAboutSpace) --- src/main/quizproject.c | 89 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/src/main/quizproject.c b/src/main/quizproject.c index f9358f9..1b97b62 100644 --- a/src/main/quizproject.c +++ b/src/main/quizproject.c @@ -2920,6 +2920,7 @@ void v_allaboutspace(void){ int space_choice; int space_score = 0; int space_answer; + int space_replay; printf("\nEnter your Astronaut name: \n"); scanf("%s", spacename); printf("\nHello, Commander %s! Pleased to have you onboard.\n\n", spacename); @@ -3013,6 +3014,94 @@ void v_allaboutspace(void){ } else { printf("\nYou tried... but time to study more about Space!\n\n"); } + + printf("Do you want to play again? (1 - yes, 0 - no): "); + scanf("%d", &space_replay); + + if(space_replay == 1) { + if (space_choice == 1) { + printf("Quiz Start!\n"); + printf("\nQuestion 1: What is the largest planet in our solar system?\n\n"); + printf("1. Earth\n"); + printf("2. Mars\n"); + printf("3. Jupiter\n"); + printf("4. Saturn\n"); + printf("\nEnter your answer: "); + scanf("%d", &space_answer); + if (space_answer == 3) { + printf("\nCorrect!\n"); + space_score++; + } else { + printf("\nIncorrect\n"); + } + } + printf("\nQuestion 2: What is the smallest planet in our solar system?\n\n"); + printf("1. Mercury\n"); + printf("2. Mars\n"); + printf("3. Venus\n"); + printf("4. Pluto\n"); + printf("\nEnter your answer: "); + scanf("%d", &space_answer); + if (space_answer == 1) { + printf("\nCorrect!\n"); + space_score++; + } else { + printf("\nIncorrect\n"); + } + + printf("\nQuestion 3: What is the name of the first man-made satellite to be launched into space?\n\n"); + printf("1. Sputnik 1\n"); + printf("2. Apollo 11\n"); + printf("3. Vostok 1\n"); + printf("4. Explorer 1\n"); + printf("\nEnter your answer: "); + scanf("%d", &space_answer); + if (space_answer == 1) { + printf("\nCorrect!\n"); + space_score++; + } else { + printf("\nIncorrect\n"); + } + + printf("\nQuestion 4: What is the name of the first man to walk on the Moon?\n\n"); + printf("1. Neil Armstrong\n"); + printf("2. Buzz Aldrin\n"); + printf("3. Yuri Gagarin\n"); + printf("4. Valentina Tereshkova\n"); + printf("\nEnter your answer: "); + scanf("%d", &space_answer); + if (space_answer == 1) { + printf("\nCorrect!\n"); + space_score++; + } else { + printf("\nIncorrect\n"); + } + + printf("\nQuestion 5: What is the name of the first successful interplanetary probe?\n\n"); + printf("1. Pioneer 10\n"); + printf("2. Mariner 2\n"); + printf("3. Viking 1\n"); + printf("4. Luna 1\n"); + printf("Enter your answer: "); + scanf("%d", &space_answer); + if (space_answer == 1) { + printf("\nCorrect!\n"); + space_score++; + } else { + printf("\nIncorrect\n"); + } + + printf("\nYour score is: %d\n\n", space_score); + if (space_score == 5) { + printf("\nCongratulations! You are ready to take off!\n\n"); + } else if (space_score >= 3) { + printf("\nGood job! But you need some more training before you venture into space.\n\n"); + } else { + printf("\nYou tried... but time to study more about Space!\n\n"); + } + } else{ + + } }