public static void startQuiz() //Method to run the spelling quiz { Console.WriteLine("Welcome to the School Spelling Quiz" + Environment.NewLine + "Press Enter to begin" + Environment.NewLine); //Welcomes the user Console.ReadLine(); List <double> decimalScore = SpellingList.studentGuess(); //Calls the method to run through each question in the quiz Console.WriteLine(""); Console.WriteLine("You got A Scrore of {0} ({1}%)", decimalScore.ElementAt(0), decimalScore.ElementAt(1) * 100); //Displays the users score as a total and a percentage Console.ReadLine(); System.Environment.Exit(1); }
public static void teacherMenu() { bool loopBreak = false; do { Console.WriteLine(""); //Lists out all options for the teacher Menu Console.WriteLine("What would you like to do?" + Environment.NewLine); Console.WriteLine("Press V to: view all of the students currently enrolled"); Console.WriteLine("Press S to: enroll an additional student"); Console.WriteLine("Press R to: remove a student from the class"); Console.WriteLine("Press A to: view all questions & answers"); Console.WriteLine("Press Q to: add another question to the quiz"); Console.WriteLine("Press D to: remove a question from the quiz"); Console.WriteLine("Press X to: exit the software" + Environment.NewLine); string choice = Console.ReadLine().ToUpper(); //Stores the user's choice choice = teacherChoice(choice); if (choice == "V") { SchoolLogins.studentList(); //Call the method to view all users } else if (choice == "S") { SchoolLogins.addStudent(); //Call the methods to add a user } else if (choice == "R") { SchoolLogins.removeStudent(); //Calls the methods to remove a student } else if (choice == "A") { SpellingList.quizOutput(); //Calls the method to view all questions and correct answers } else if (choice == "Q") { SpellingList.addWord(); //Calls the method to a question & answer } else if (choice == "D") { SpellingList.removeWord(); //Calls the method to remove a question & answer } else if (choice == "X") { System.Environment.Exit(1); //Closes the software } else { Console.WriteLine("Unknown Input Detected | Try again" + Environment.NewLine); //If the user's choice doesn't match, return an error } } while (loopBreak == false); }
public static List <double> studentGuess() //Method for checking student's guess against stored answer { SpellingList.generateHints(); //calls the method to generate hints bool hintUsed = false; do { if (hintUsed == true) //If student has requested hint { Console.WriteLine("First Letter Hint: {0}", quizHints.ElementAt(questionNumber)); //display the first letter of the current answer } Console.WriteLine(quizWords.Keys.ElementAt(questionNumber)); //Asks the next question if (hintUsed == false) //If user hasn't already asked for a hint for this question { Console.WriteLine("Type 'Hint' to get a hint | Warning! Doing so will cost you a point of your score"); } //Let the user know that they can request a hint string studentAnswer = Console.ReadLine().ToUpper(); string correctAnswer = quizWords.Values.ElementAt(questionNumber); int characterLetter = 0; int wordScore = 10; //Sets maximum score possible for each word int wrongScore = 0; if (studentAnswer == "HINT") { hintUsed = true; studentScore = studentScore - 1; //If hint has been used, deduct a point from the student's total score } else { char[] guessCharacters; guessCharacters = studentAnswer.ToCharArray(0, studentAnswer.Length); //Seperates each character of student's answer into a character array char[] answerCharacters; answerCharacters = correctAnswer.ToCharArray(0, correctAnswer.Length); //Seperates each chatacter of the correct answer into a charatcer array do { if (guessCharacters.ElementAt(characterLetter) == answerCharacters.ElementAt(characterLetter)) //if the current letter from each char array match { characterLetter++; //move onto next letter } else if (guessCharacters.ElementAt(characterLetter) != answerCharacters.ElementAt(characterLetter)) //if the two letters don't match { characterLetter++; //move onto next letter wrongScore++; //increase the count of incorrect letters } } while (characterLetter != studentAnswer.Length); Console.WriteLine("The correct answer is: {0}", correctAnswer + Environment.NewLine); //Display the correct answer for the question if (wrongScore >= (correctAnswer.Length / 2) | studentAnswer.Length <= (correctAnswer.Length / 2)) //If the number of incorrect letters is at least half the length of the current correct answer { wrongScore = 10; //inncorect letters count is set to max } wordScore = wordScore - wrongScore; //score for this word is calculated through deducting a point for each incorrect letter from the maximum total score studentScore = studentScore + wordScore; //add score for this word to the student's total score questionNumber++; hintUsed = false; //resets whether a hint has been used }; } while (questionNumber != quizWords.Keys.Count); //runs until all questions have been asked List <double> calculatedScore = new List <double>(); calculatedScore = SpellingList.scoreCalculation(studentScore); //passes the score of the student to the method for calculating the percentage return(calculatedScore); }