Answer to Question #252022 in C# for aj jarikpe

Question #252022


    // 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);


question1

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

    grade = MarkToGrade();


1
Expert's answer
2021-10-16T11:02:39-0400
using System;
using System.Collections.Generic;


namespace Questions
{
    class Program
    {
        static char MarkToGrade(int mark)
        {
            if (mark >= 90 && mark <= 100)
                return 'A';
            if (mark >= 80 && mark < 90)
                return 'B';
            if (mark >= 70 && mark < 80)
                return 'C';
            if (mark >= 60 && mark < 70)
                return 'D';
            if (mark >= 50 && mark < 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("\nLastname: " + 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
APPROVED BY CLIENTS