Answer to Question #336361 in C# for Siyanda

Question #336361

a) Write a method GetOneStudent that asks a student for both of his/her WRAV101 and

WRSC111 marks (each as a real number). The method must return both of these marks. The

method must ensure that each of the marks is in the range 0 to 100.

b) Write a method CanContinue that takes as input two marks, one for WRAV101 and one for

WRSC111. Each of these marks is in the range 0 to 100. The method must return the value

true if both of these marks are at least 50, otherwise the method must return the value false.

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


1
Expert's answer
2022-05-02T18:05:02-0400
internal class Program
    {
        public static double[] GetOneStudent()
        {
            double[] marks = new double[2];
            while (true)
            {
                Console.WriteLine("Enter WRAV101");
                marks[0] = double.Parse(Console.ReadLine());
                if (marks[0] > 0 && marks[0] < 100)
                    break;
            }


            while (true)
            {
                Console.WriteLine("Enter WRSC111");
                marks[1] = double.Parse(Console.ReadLine());
                if (marks[1] > 0 && marks[1] < 100)
                    break;
            }


            return marks;
        }
        public static bool CanContinue(double[] marks)
        {
            if (marks[0] >= 50 && marks[1] >= 50)
                return true;
            return false;
        }


        public static void DisplayDecision(double[] marks)
        {
            if (CanContinue(marks))
            {
                Console.WriteLine($"You can continue with the second semester modules. Your GPA: {marks.Sum() / marks.Length}");
                return;
            }
            Console.WriteLine($"You cannot continue studying the modules of the second semester. Your GPA: {marks.Sum() / marks.Length}");
        }
        static void Main(string[] args)
        {
            DisplayDecision(GetOneStudent());
            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