Answer to Question #252020 in C# for aj jarikpe

Question #252020


    // declare variables

    int inpMark;

    string lastName;

    char grade = MarkToGrade;


    // enter the student's last name

    Console.Write("Enter the last name of the student => ");

    lastName = Console.ReadLine();

    // enter (and validate) the mark

    do

    {

      Console.Write("Enter a mark between 0 and 100 => ");

      inpMark = Convert.ToInt32(Console.ReadLine());

    } while (inpMark < 0 || inpMark > 100);


   * // Use the method to convert the mark into a letter grade

    grade = MarkToGrade();

question is to use the method to convert the mark into a letter grade


1
Expert's answer
2021-10-16T11:02:36-0400
using System;


namespace Questions
{
    class Program
    {
        static char MarkToGrade(int studentMark)
        {
            if (studentMark >= 90 && studentMark <= 100)
                return 'A';
            if (studentMark >= 80 && studentMark < 90)
                return 'B';
            if (studentMark >= 70 && studentMark < 80)
                return 'C';
            if (studentMark >= 60 && studentMark < 70)
                return 'D';
            if (studentMark >= 50 && studentMark < 60)
                return 'E';
            return 'F';
        }
        static void Main()
        {


            // declare variables


            int inpMark;


            string lastName;


            // enter the student's last name


            Console.Write("Enter the last name of the student => ");


            lastName = Console.ReadLine();


            // enter (and validate) the mark


            do


            {


                Console.Write("Enter a mark between 0 and 100 => ");


                inpMark = Convert.ToInt32(Console.ReadLine());


            } while (inpMark < 0 || inpMark > 100);


            char grade = MarkToGrade(inpMark);


            Console.WriteLine();
            Console.WriteLine("Lastname: " + lastName);
            Console.WriteLine("Grade: " + grade);




            Console.WriteLine();
            Console.ReadKey();
        }
    }


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS