write a program which uses a class with the name Student, the class will have as data
- name
- AM
- grade1
- grade2
- grade3
all the data of the class have to be private
the program will ask the elements of two students, it will save them as objects and will show the final average of the two averages of the two students
how i will make my objects private? what changes i have to do? Also, the count of the averages i want to be in the class Student.... help me please
using System;
class Student
{
public string name;
public int AM;
public double grade1;
public double grade2;
public double grade3;
}
class Program
{
static void Main()
{
Student st1= new Student();
Student st2= new Student();
Console.WriteLine("give the elements of the firts student:");
Console.WriteLine("Name:");
st1.name= Console.ReadLine();
Console.Write("AM:T0");
st1.AM = Int32.Parse(Console.ReadLine());
Console.WriteLine("first grade:");
st1.grade1=Double.Parse(Console.ReadLine());
Console.WriteLine("second grade:");
st1.grade2=Double.Parse(Console.ReadLine());
Console.WriteLine(" third grade:");
st1.grade3=Double.Parse(Console.ReadLine());
Console.WriteLine("give the elements of the second student:");
Console.WriteLine("name:");
st2.name= Console.ReadLine();
Console.Write("AM:T0");
st2.AM = Int32.Parse(Console.ReadLine());
Console.WriteLine("first grade:");
st2.grade1=Double.Parse(Console.ReadLine());
Console.WriteLine("second grade:");
st2.grade2=Double.Parse(Console.ReadLine());
Console.WriteLine(" third grade:");
st2.grade3=Double.Parse(Console.ReadLine());
double AV1,AV2,sum;
AV1= (grade1+grade2+grade3)/3;
AV2=(grade1+grade2+grade3)/3;
sum=(AV1+AV2)/2;
Console.WriteLine("the average is {0}",sum);
Console.ReadKey();
}
}