Hi,
for example:
In X board if you fail in 1 subject, the final result will show as fail only. Even if you score above 90.
I want a logic for code which should show as fail in the result section even if 1 subject score is less than 35 .
In my code it is showing as first class even if I put 34 in one of the subject.
Please let me know what logic should be applied.
Thanks,
Anurag
Anurag


Amit GuptaRank #190 · 12.8K reputationPosted Mar 28, 2017, 5:33 AM EDT
Tapan PatelRank #614 · 3.9K reputationPosted Mar 28, 2017, 5:45 AM EDT
Anurag Gn36 reputationPosted Mar 28, 2017, 6:18 AM EDT
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace student_marks { class studentprofile { static void Main(string[] args) { //int subject1, subject2, subject3, subject4, subject5, subject6, total; //double percentage; char option; Console.WriteLine("-------Welcome to percentage and grade calculator of SSLC 2017-------"); Console.WriteLine("\nPlease enter your name"); string UserName = Console.ReadLine(); Console.Write("\nEnter the 1st Language Marks "); int subject1 = Convert.ToInt32(Console.ReadLine()); if(subject1 { option = '5'; //Console.Write("\nThe student has failed in 1st language"); } Console.Write("\nEnter the 2nd Language Marks "); int subject2 = Convert.ToInt32(Console.ReadLine()); if(subject2 { option = '5'; //Console.Write("\nThe student has failed in 2nd language"); } Console.Write("\nEnter the 3rd Language Marks "); int subject3 = Convert.ToInt32(Console.ReadLine()); if(subject3 { option = '5'; //Console.Write("\nThe student has failed in 3rd language"); } Console.Write("\nEnter the MATHEMATICS Marks "); int subject4 = Convert.ToInt32(Console.ReadLine()); if(subject4 { option = '5'; //Console.Write("\nThe student has failed in MATHEMATICS"); } Console.Write("\nEnter the SCIENCE Marks "); int subject5 = Convert.ToInt32(Console.ReadLine()); if(subject5 { option = '5'; //Console.Write("\nThe student has failed in SCIENCE"); } Console.Write("\nEnter the SOCIAL STUDIES Marks "); int subject6 = Convert.ToInt32(Console.ReadLine()); if(subject6 { option = '5'; //Console.Write("\nThe student has failed in SOCIAL STUDIES"); } int[] sub = new int[5]; sub[0] = subject1; sub[1] = subject2; sub[2] = subject3; sub[3] = subject4; sub[4] = subject5; sub[5] = subject6; studentprofile sp = new studentprofile(); int total = sp.Add(subject1,subject2,subject3,subject4,subject5,subject6); double percentage = sp.percentage(total); if (percentage > 85) { option = '1'; } else if (percentage 60) { option = '2'; } else if (percentage 50) { option = '3'; } else if (percentage = 35) { option = '4'; } else { option = '5'; } Console.WriteLine("\nThe total marks, percentage and grade of Student {0} is", UserName); Console.WriteLine("\nTOTAL MARKS : {0}", total); Console.WriteLine("\nPERCENTAGE : {0}", percentage); switch (option) { case '1': Console.WriteLine("\nGrade: First Class with Distinction"); break; case '2': Console.WriteLine("\nGrade: First Class"); break; case '3': Console.WriteLine("\nGrade: Second Class"); break; case '4': Console.WriteLine("\nGrade: Third Class"); break; case '5': Console.WriteLine("\nSorry you are FAILED"); break; default: Console.WriteLine("\nInvalid GRADE"); break; } Console.ReadLine(); } public int Add(int subject1, int subject2, int subject3, int subject4, int subject5, int subject6) { return subject1 + subject2 + subject3 + subject4 + subject5 + subject6; } public double percentage(int total) { return ((total/625f)*100); } } }Anurag Gn36 reputationPosted Mar 28, 2017, 6:29 AM EDT
Tapan PatelRank #614 · 3.9K reputationPosted Mar 28, 2017, 6:48 AM EDT