mercredi 1 janvier 2020

No Notified Errors But The Code Doesn't Perform As Instructed

Still in the early beginning stages of constructing various problems that can be solved with if-statements. One in particular that I am solving right now is a grading system in which the user inputs a number grade and the output is given showing their corresponding letter grade. There are no errors but it doesn't output the corresponding letter grade from my input.

            string goodGrade = "A";
            string okGrade = "B";
            string fairGrade = "C";
            string passGrade = "D";
            string failGrade = "F";
            string perfectGrade = "A+";
            int minGrade = 0;
            int maxGrade = 100;
            string inputLetterGrade;
            int inputNumberGrade;
            int studentA, studentB, studentC, studentD, studentE;
            int averageNumberGrade;
            string averageLetterGrade;
            studentA = 95;
            studentB = 84;
            studentC = 36;
            studentD = 72;
            studentE = 51;

            Console.Write("Insert Number Grade: ");
            inputNumberGrade = Convert.ToInt32(Console.ReadLine());

            if (inputNumberGrade == maxGrade) {
                Console.WriteLine("perfect you got an {0}", perfectGrade);

                if (inputNumberGrade <= 99 || inputNumberGrade >= 80)
                {
                    Console.WriteLine($"You got an {goodGrade}");

                    if (inputNumberGrade <= 79 || inputNumberGrade >= 70)
                    {
                        Console.WriteLine($"You got a {okGrade}");

                        if (inputNumberGrade <= 69 || inputNumberGrade >= 60)
                        {
                            Console.WriteLine($"You got a {fairGrade}");

                            if (inputNumberGrade <= 59 || inputNumberGrade >= 50)
                            {
                                Console.WriteLine("Poor performance, you got a {0}", passGrade);

                                if (inputNumberGrade >= 40 || inputNumberGrade <= 49)
                                {
                                    Console.WriteLine($"You fail, you got an {failGrade}");
                                }

                                else if (inputNumberGrade < 40 && inputNumberGrade != 0)
                                {
                                    Console.WriteLine($"You fail, you got an {failGrade}");
                                }

                                if ((inputNumberGrade != 0) == (inputNumberGrade == maxGrade))
                                {
                                    //Re-enter score to reflect whether or not the end-result is a positive or negative letter grade
                                    Console.Write("Re-enter Score: ");
                                    GetInputNumberGrade(inputNumberGrade);


                                }
                            }
                        }
                    }
                }

            }

Console Output Image

Aucun commentaire:

Enregistrer un commentaire