Answer to Question #320399 in C# for kun

Question #320399

Write a program that does the following for 15



students:



 Reads in 3 marks for each student (you



need to ensure that only valid marks



between 0 and 100 are processed) – your



prompt message to the user should



indicate which number is being requested



(see example image of output)



 Calculates and displays the highest mark



for each student.



Finds and displays the highest mark in the class.



(Note: The example output only shows data for 5



students, but your program must work for 15



students).

1
Expert's answer
2022-03-30T14:10:32-0400
using System;

namespace students
{
    class Program
    {
        public static void Main(string[] args)
        {
            int n = 2;
            int max_mark;
            int[,] marks = new int[n,3];
            for (int i = 0; i<n; i++)
                for (int j=0; j<3; j++)
                {
                    Console.Write("Enter sudetnt {0}, mark {1}: ", i+1, j+1);
                    marks[i,j]=Convert.ToInt32(Console.ReadLine());
                    while ((marks[i,j]<0) || (marks[i,j]>100))
                    {
                        Console.WriteLine();
                        Console.Write("Mark is invalid.\nPlease re-input mark: ");
                        marks[i,j]=Convert.ToInt32(Console.ReadLine());
                    }
                }
                
            Console.WriteLine();
            for (int i = 0; i<n; i++)
            {
                max_mark = marks[i,0];
                for (int j = 0; j<3; j++)
                {
                    if (max_mark < marks[i,j])
                    {
                        max_mark = marks[i,j];                        
                    }
                }
                Console.WriteLine("Student {0} highest mark: {1}", i+1, max_mark);
            }

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

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