Answer to Question #345810 in C# for Lee

Question #345810

Using C# and Visual Studio, design and implement a standalone command line application that can be used to calculate the average grade for a student doing four course:

1. Create a class called Grading to do the following:

2. In Grading class, the student must enter their name, Surname, StudentId (Use getters and setters for all variables)

3. In Grading class, the student must capture his/her final marks for PROG6211, CLDV6211, DBAS6211, and SAND6211, the marks must be captured into an array

4. In Grading class, Create a method that takes the array of marks as a parameter and returns a calculated average for all marks

5. Create another class Called FinalGrading that contain a method with a switch statement to grade the average returned mark.

a. Average mark >=75 => Frist Class

b. Average mark between 74% and 65% => Second class

c. Average mark between 50% and 64% => Third class

d. Average mark less than 50% => Fail


1
Expert's answer
2022-05-30T15:15:55-0400
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace CSharp_Shell
{
	class Grading
	{
		public double CalculatedAverage()
		{
			return Marks.Sum() / 4f;
		}
		
		public string Name {get; set;}
		public string Surname {get; set;}
		public uint StudentId {get; set;}
		
		public string[] Items {get; set;} = new string[]{"PROG6211", "CLDV6211", "DBAS6211", "SAND6211"};
		public List<int> Marks {get; set;} = new List<int>();
	}
	
	static class FinalGrading
	{
		static public string ReturnedMark(double average, int maxMark)
		{
			double p = average / maxMark;
			
			if(p >= .75)
				return "Frist Class";
			if(p >= 0.65)
				return "Second class";
			if(p >= 0.5)
				return "Third class";
			return "Fail";
		}
	}
	
    public class Program 
    {
        public static void Main()
        {
        	var grading = new Grading();
        	
			Console.Write("Name: ");
			grading.Name = Console.ReadLine();
			Console.Write("Surname: ");
			grading.Surname = Console.ReadLine();
			Console.Write("StudentId: ");
			uint id;
			uint.TryParse(Console.ReadLine(), out id);
			grading.StudentId = id;
			int mark;
			int maxMark;
			Console.Write("Max mark: ");
			int.TryParse(Console.ReadLine(), out maxMark);
			foreach(var item in grading.Items)
			{
				Console.Write($"{item}: ");
				int.TryParse(Console.ReadLine(), out mark);
				grading.Marks.Add(mark);
			}
			
			Console.WriteLine($"{grading.StudentId} {grading.Name} {grading.Surname} : {FinalGrading.ReturnedMark(grading.CalculatedAverage(), maxMark)}");
        }
    }

}


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