i need help with my code
Give the class methods to provide name and SID to a newly created Object
(a constructor) and a method to determine the Grade of a piece of work.
and to Write a Main method in another class which creates an instance of this class and tests the methods.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Homework_task_F
{
class StudentDetails //class for Declarations
{
public string studentname;
public string studentsid;
public string studentgrade;
}
class Students
{
public List<StudentDetails> studList = new List<StudentDetails>();
//This list contains the student list
public int MaxStudents;
//This Function Adds the Record
public int AddRecord(string name, string sid, string grades)
{
StudentDetails stud = new StudentDetails();
stud.studentname = name;
stud.studentsid = sid;
stud.studentgrade = grades;
studList.Add(stud);
MaxStudents = studList.Count;
return 1;
}
}
class Program
{
static public Students theStudents = new Students();
public static double Grade;
//This method is to view Records as Report
static public void ViewRecords()
{
Console.WriteLine("__________________________________________________________________________");
Console.WriteLine("SNo Student Name SID Grade ");
Console.WriteLine("__________________________________________________________________________");
for (int i = 0; i < theStudents.MaxStudents; i++)
{
Console.Write("{0, -5}", i + 1);
Console.Write("{0, -15}", theStudents.studList[i].studentname);
Console.Write("{0, -10}", theStudents.studList[i].studentsid);
Console.Write("{0, -20}", theStudents.studList[i].studentgrade);
if (Grade >= 70 && Grade <= 100)
{
Console.Write("you Pass First Class \n");
}
if (Grade >= 60 && Grade <= 69)
{
Console.Write(" you is Pass Upper Second Class \n");
}
if (Grade >= 50 && Grade <= 59)
{
Console.Write(" you Pass Lower Second Class \n");
}
if (Grade >= 40 && Grade <= 49)
{
Console.Write(" you Pass 3rd Class \n");
}
if (Grade >= 0 && Grade <= 39)
{
Console.Write(" sorry you failed \n");
}
if (Grade >100)
{
Console.Write("Error \n");
}
}
Console.WriteLine("__________________________________________________________________________");
}
static public void InputRecords()
{
Console.Write("Student Name: \n");
string name;
name = Console.ReadLine();
Console.Write("Student SID: \n");
string sid;
sid = Console.ReadLine();
Console.Write("Student Grade: \n");
string grade;
grade = Console.ReadLine();
theStudents.AddRecord(name, sid, grade);
}
static void Main(string[] args)
{
Console.WriteLine("Student MarkList Application");
Console.Write("Enter the Total number of students: ");
int numStudents = -1;
string s = Console.ReadLine();
numStudents = Convert.ToInt32(s);
for (int i = 1; i <= numStudents; i++)
{
Console.WriteLine("\nEnter " + i.ToString() + " Student Information\n");
InputRecords();
}
ViewRecords();
Console.ReadKey();
}
}
}