/// <summary> /// Print results. /// </summary> public static void Print(int questions, double skillLevel) { double[] gradeProbabilities = ExpectedGrade.CalculateGradeProbabilities(questions, skillLevel); double expectedGrade = ExpectedGrade.CalculateExpectedGrade(questions, skillLevel); double[] gradeOdds = new double[5]; for (int i = 0; i < 5; i++) { gradeOdds[i] = 1 / gradeProbabilities[i]; } Console.WriteLine("\nQuestions: " + questions); Console.WriteLine($"Skill Level: {skillLevel} ({Math.Round(100 * skillLevel)}% chance to get each question correct)\n"); Console.WriteLine($"{"Grade", -10} {"Chance", -10} {"Odds", -10}\n"); for (int i = 0; i < gradeProbabilities.Length; i++) { Console.WriteLine($"{(double)i, -10} {Math.Round(gradeProbabilities[i], 5), -10} 1 in {Math.Round(gradeOdds[i], 1), -10}"); } Console.WriteLine("\nExpected Grade: " + Math.Round(expectedGrade, 2) + "\n"); }
static void Main(string[] args) { int questions = Convert.ToInt32(args[0]); double skillLevel = Convert.ToDouble(args[1]); if (questions > 170) { throw new OverflowException("Number of questions cannot be greater than 170."); } else if (questions < 1) { throw new ArithmeticException("Number of questions cannot be less than 1."); } if (skillLevel > 1) { throw new ArithmeticException("Skill level cannot be greater than 1."); } else if (skillLevel < 0) { throw new ArithmeticException("Skill level cannot be less than 0."); } ExpectedGrade.Print(questions, skillLevel); }