Implement in c sharp to create a grading program with following grading policies
ID: 3591220 • Letter: I
Question
Implement in c sharp to create a grading program with following grading policies for a computer science class offered in ABC University a). There are two quizzes, each graded on the basis of 10 points. b). There is one midterm and one final, each graded on the basis of 100 points. c). The final counts for 40% of the grade, the midterm counts for 30%, and the two quizzes together count for a total of 30%. Define and use a structure for the student record including the grade of each quiz and the grade of each test. Also, define a class to calculate the student’s numeric score for the entire course and letter grade for the class.
Explanation / Answer
using System;
struct StudentGrade //structure
{
public double quiz1;
public double quiz2;
public double midterm;
public double final;
public double score;
public string grade;
};
public class GradeTest
{
public static void Main()
{
StudentGrade sd1; //structure variable
//input scores in local variables
Console.WriteLine("Enter score in quiz1(0-10) : ");
double quiz1 = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter score in quiz2(0-10) : ");
double quiz2 = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter score in midterm(0-100) : ");
double midterm = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter score in final(0-100) : ");
double final = Convert.ToDouble(Console.ReadLine());
//assign local variable values to structure
sd1.quiz1 = quiz1;
sd1.quiz2 = quiz2;
sd1.midterm = midterm;
sd1.final = final;
//compute final score
double score = ((sd1.quiz1+sd1.quiz2)*0.4 + sd1.midterm*0.3 +sd1.final*0.3);
sd1.score = score;
//assign final grade
Console.WriteLine(" final score of student : "+sd1.score);
if(sd1.score > 80 && sd1.score <= 100)
sd1.grade = "A";
else if(sd1.score >70 && sd1.score <=80)
sd1.grade = "B";
else if(sd1.score >60 && sd1.score <=70)
sd1.grade = "C";
else if(sd1.score >50 && sd1.score <=60)
sd1.grade = "D";
else if(sd1.score >40 && sd1.score <=50)
sd1.grade = "E";
else
sd1.grade = "Fail";
Console.WriteLine(" final grade of Student : "+sd1.grade);
}
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.