Guest User

Guest User

  • Tech Writer
  • 4
  • 3.3k

Convert Rows to Columns using C# logic with entity framework

Apr 2 2021 4:43 AM
  1. The Students studying in BE Final Year. In Final year they have Four Theory Subjects.

    List of Subjects and their max and passing marks are as below:

    1. EC1 – Max marks 100 . Passing marks 30

    2. EC2– Max marks 100 . Passing marks 30

    3. EC3– Max marks 100 . Passing marks 30

    4. EC4– Max marks 100 . Passing marks 30

    5. EC5– Max marks 100 . Passing marks 30

    The individual marks are stored in the table like below.

    Table Name: Students

    StudentID

    StudentName

    SubjectName

    Marks

    1

    Savita

    EC1

    50

    1

    Savita

    EC2

    55

    1

    Savita

    EC3

    28

    1

    Savita

    EC4

    30

    1

    Savita

    EC5

    35

    Problem:

    1. You have to write a program to display the list of candidates along with their individual subject marks and total marks like below.

    StudentName

    EC1

    EC2

    EC3

    EC4

    EC5

    Total

    Savita

    50

    55

    28

    30

    30

    193

    Harish

    55

    60

    30

    35

    30

    210

    2. Add logic to your code such that this list of students displayed is in order. The person with maximum total marks is at the top and the person with the least marks is at the bottom.

    StudentName

    EC1

    EC2

    EC3

    EC4

    EC5

    Total

    Harish

    55

    60

    30

    35

    30

    210

    Savita

    50

    55

    28

    30

    30

    193

    3. Add a button [Show Results of All]. When clicked, displays the Pass or Fail status for all the students.

    Logic is simple: If a student has failed in any subject, he is fail.

    StudentName

    EC1

    EC2

    EC3

    EC4

    EC5

    Result

    Total

    Harish

    55

    60

    30

    35

    30

    Pass

    210

    Savita

    50

    55

    28

    30

    30

    Fail

    193

    4. Add a button [Show Results with Grace Marks]. When clicked, display Results with Grace Marks, the program has to add Grace Marks to failed students following a logic. Pass/Fail status has to be displayed for all the students after the Grace Marks are added.

    Logic is: Total grace marks per student is max of 6 marks. If the candidate has failed in two subjects with 28 marks in EC1 and 27 marks in EC2, then after grace marks EC1 = 30 and EC2=30. The candidate is declared pass.

    If the candidate has secured 25 marks in EC1 and 28 marks in EC2, then the total grace marks needed is 5+2 (7 marks). Hence the student is declared fail and no grace marks are given. Please note that Grace marks can be given to max of 2 subjects only. If Candidate has failed in more than 2 subjects then he is failed and no grace marks are given.

    StudentName

    EC1

    EC2

    EC3

    EC4

    EC5

    Result

    Total

    Harish

    55

    60

    30

    35

    30

    Pass

    210

    Savita

    50

    55

    30

    30

    30

    Pass

    195

    Please Don’t use any SQL functions (stored procedure, views, pivot etc). All logic should be done in BLL

Answers (4)