// 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();
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();
}
}
}
Comments
Leave a comment