Drop hier links of afbeeldingen om ze aan de editor toe te voegen.

What grade did you get in your exam?

★★★

When students sit exams their total mark for a paper, called a raw mark is converted to a uniform mark scale (UMS). The UMS enables different units to be worth more or less than other units, or marked out of a different number of raw marks. Once all the UMS marks have been calculated, grade boundaries are decided to enable the results for each year to be similar to previous years. This balances one paper being harder than another.

Exam grade

Make

Write a program that outputs the grade achieved from a mark, and the number of marks needed to achieve the next grade using the data in the table below.

Success Criteria

Remember to add a comment before a subprogram or selection statement to explain its purpose.

Create a subprogram called grade that:

  1. Takes a parameter mark that is an integer.
  2. It returns the grade as outlined in the table:
Mark <2 2 4 13 22 31 41 54 67 80+
Grade U 1 2 3 4 5 6 7 8 9

Create a subprogram called marks_needed that:

  1. Takes a parameter mark that is an integer.
  2. Returns the number of marks needed to achieve the next grade as shown above.

Complete the main program so that:

  1. The user can input a mark.
  2. It outputs the grade achieved.
  3. It outputs the number of marks needed to achieve the next grade.

Typical inputs and outputs from the program would be:

Enter the mark 0-100:
50
A mark of 50 is grade 6
You needed 4 more marks to achieve the next grade.
Enter the mark 0-100:
60
A mark of 60 is grade 7
You needed 7 more marks to achieve the next grade.
Enter the mark 0-100:
80
A mark of 80 is grade 9
You needed 0 more marks to achieve the next grade.
🆘 If you're really stuck, use this Parsons code sorting exercise
grade
// Return the grade from the mark
---
static string grade(int mark)
{
---
    // Eighty or more is a grade nine
    if (mark >= 80)
    {
---
        return "9";
---
    }
---
    // Sixty seven or more is a grade eight
    else if (mark >= 67)
    {
---
        return "8";
---
    }
---
    // Fifty four or more is a grade seven
    else if (mark >= 54)
    {
---
        return "7";
---
    }
---
    // Forty one or more is a grade six
    else if (mark >= 41)
    {
---
        return "6";
---
    }
---
    // Thirty one or more is a grade five
    else if (mark >= 31)
    {
---
        return "5";
---
    }
---
    // Twenty two or more is a grade four
    else if (mark >= 22)
    {
---
        return "4";
---
    }
---
    // Thirteen or more is a grade three
    else if (mark >= 13)
    {
---
        return "3";
---
    }
---
    // Four or more is a grade two
    else if (mark >= 4)
    {
---
        return "2";
---
    }
---
    // Two or more is a grade one
    else if (mark >= 2)
    {
---
        return "1";
---
    }
---
    // Less than two is unclassified
    else {
---
        return "U";
---
    }
---
}
marks_needed
// Calculate the marks needed to achieve the next grade
---
static int marks_needed(int mark)
{
---
    // Top grade already achieved
    if (mark >= 80)
    {
---
        return 0;
---
    }
---
    // Next grade is eighty marks
    else if (mark >= 67)
    {
---
        return 80 - mark;
---
    }
---
    // Next grade is sixty-seven marks
    else if (mark >= 54)
    {
---
        return 67 - mark;
---
    }
---
    // Next grade is fifty-four marks
    else if (mark >= 41)
    {
---
        return 54 - mark;
---
    }
---
    // Next grade is forty-one marks
    else if (mark >= 31)
    {
---
        return 41 - mark;
---
    }
---
    // Next grade is thirty-one marks
    else if (mark >= 22)
    {
---
        return 31 - mark;
---
    }
---
    // Next grade is twenty-two marks
    else if (mark >= 13)
    {
---
        return 22 - mark;
---
    }
---
    // Next grade is thirteen marks
    else if (mark >= 4)
    {
---
        return 13 - mark;
---
    }
---
    // Next grade is four marks
    else if (mark >= 2)
    {
---
        return 4 - mark;
---
    }
---
    // First grade is two marks
    else
    {
---
        return 2 - mark;
---
    }
---
}
Main program
// -------------------------
// Main program
// -------------------------
---
public static void Main(string[] args)
{
---
    Console.WriteLine("Enter the mark 0-100:");
    int my_mark = Convert.ToInt32(Console.ReadLine());
---
    string my_grade = grade(my_mark);
    int next_grade = marks_needed(my_mark);
---
    Console.WriteLine($"A mark of {my_mark} is grade {my_grade}");
    Console.WriteLine($"You needed {next_grade} more marks to achieve the next grade.");
}