C# exercises and solutions- student records


C# structure: student records application

Exercise:

Write a C# program to keep records and perform statistical analysis for a class of 20 students. The information of each student contains ID, Name, Sex, quizzes Scores (2 quizzes per semester), mid-term score, final score, and total score.
The program will prompt the user to choose the operation of records from a menu as shown below:

========================================================

                                                   MENU

========================================================

1. Add student records

2. Delete student records

3. Update student records

4. View all student records

5. Calculate an average of a selected student’s scores

6. Show student who gets the max total score

7. Show student who gets the min total score

8. Find student by ID

9. Sort records by total scores

Enter your choice:1


Note: All students records are stored in an array of structures

Solution:

To make this solution simple and easy to follow, we divide this solution in to different steps:

Step1: Declaring a structure called student to store the records

struct student

{
public string stnumber;

public string stname;

public string sex;

public float quizz1;

public float quizz2;

public float assigment;

public float midterm;

public float final;

public float total;


};




Comments

DBizzle comment

 DBizzle

I don't see much reason to use a struct here when we could use a class with properties.


2016-04-17
Antonia comment

 Antonia

Why would anyone use a struct in an OO language when they can use class instead? Any tips?


2015-07-29



This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.