Hello thank you everyone for seeing this question.
So.. i have a code that i have to write and i couldn't i've tried my best in it i tried talking to other programmers but, none of it help me for real.
- Create a class named "student".
- Class' attributes are "name" and "grade".
- The class' method is "Rate", which receives the name and grade of the student and print "pass" if the grade >= 60, else "failed".
- create three different objects for three students
I need to take the name from the user i did not know how
And here is my best try code:
class Program
{
static void Main(string[] args)
{
student a = new student("omar", 55);
Console.WriteLine("Omar has a grade of 55 so he {1}!", a.Rate());
student b = new student("ahmed", 91);
Console.WriteLine("Ahmed has a grade of 91 so he {0}!", b.Rate());
student c = new student("mohammed", 22);
Console.WriteLine("Mohammed has a grade of 22 so he {0}!", c.Rate());
Console.ReadKey();
}
}
class student
{
string name;
double grade;
public student(string name, double grade)
{
this.name = name;
this.grade = grade;
}
public string Rate()
{
if (grade >= 60)
{
return "passed";
}
else
{
return "failed";
}
}
}
}