Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Student
- {
- private string name;
- public string Name
- {
- get { return name; }
- }
- private double[] testScores;
- public Student(string theName, double[] theScores)
- {
- name = theName;
- testScores = theScores;
- }
- public double ComputeAverage()
- {
- double total = 0.0;
- foreach (double score in testScores)
- total += score;
- return (total / 4);
- }
- }
- public class StudentTest1
- {
- public static void Main()
- {
- double[] scores = { 90.0, 80.0, 80.0, 90.0 };
- Student student;
- student = new Student("Alice Smith", scores);
- Console.WriteLine("Average for {0} is {1:F1}", student.Name,
- student.ComputeAverage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement