Answer to Question #335568 in C# for Siyanda

Question #335568

c) Write a method DisplayDecision that takes as input two marks, one for WRAV101 and one

for WRSC111. Each of these marks is in the range 0 to 100. If the student can continue with

the second semester modules (use CanContinue above), an appropriate message and the

average mark for the two modules is displayed, otherwise the student is informed that he may

not continue.

d) Now, write the main program that continuously does the following for any number of students

until the lecturer requests to terminate the process:

 Ask for the WRAV101 and WRSC111 marks and display a message to indicate whether

the student can continue with second semester modules or not.


1
Expert's answer
2022-04-29T18:23:04-0400
class Program
{
    static void Main()
    {
        (int WRAV101, int WRSC111) = GetOneStudent();
        DisplayDecision(WRAV101, WRSC111);
    }




    static (int WRAV101, int WRSC111) GetOneStudent()
    {
        return (Read("Enter the WRAV101 mark (0-100): "),
            Read("Enter the WRAV101 mark (0-100): "));
    }


    static void DisplayDecision(int WRAV101, int WRSC111)
    {
        string message = CanContinue(WRAV101, WRSC111) ?
            "Student can continue studing!" :
            "Students can not continue studing!";


        Console.WriteLine(message);
    }




    static bool CanContinue(int WRAV101, int WRSC111)
    {
        return new int[] { WRAV101, WRSC111 }.All(m => m >= 50);
    }




    static int Read(string message, int min = 0, int max = 100)
    {
        while (true)
        {
            Console.Write(message);
            if (int.TryParse(Console.ReadLine(), out int result) &&
                result >= min && result <= max)
                return result;
            Console.WriteLine("Incorrect value of mark, pleae, try again!");
        }
    }
}

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