[Csharp]
/* (Start of program header annotation)
* Copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* All rights reserved.
* File name: defines the class that describes the basic information of the student, sets the name, sets the score for the three courses, and calculates the total score and average score.
* Author: Lei hengxin
* Completion date: January 1, September 22, 2012
* Version No.: V1.0
* Description of tasks and Solutions
* Input description:
* Problem description:
* Program output:
* End the comment in the program Header
*/
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Namespace Four _ week
{
Class Program
{
Static void Main (string [] args)
{
Student stu = new Student ();
Console. Write ("Enter the student's name :");
String name = Console. ReadLine ();
Console. Write ("Enter the student's Chinese score :");
Double Chinese = double. Parse (Console. ReadLine ());
Console. Write ("Enter your student's score :");
Double Math = double. Parse (Console. ReadLine ());
Console. Write ("Enter your English score :");
Double English = double. Parse (Console. ReadLine ());
Stu. set_name (name );
Stu. set_Math (Math );
Stu. set_English (English );
Stu. set_Chinese (Chinese );
Double sun = stu. sum_score ();
Double average = stu. average_score ();
Console. WriteLine ("total score of this student: {0}", sun );
Console. WriteLine ("the average score of this student is {0}", average );
Console. ReadKey (true );
}
}
Class Student
{
Public string name;
Public double Chinese;
Public double Math;
Public double English;
Public Student (string name, double Chinese, double Math, double English)
{
Name = "";
Chinese = 0;
Math = 0;
English = 0;
}
Public Student ()
{
Name = "";
Chinese = 0;
Math = 0;
English = 0;
}
Public void input_data ()
{
Console. WriteLine ("Name: Chinese, mathematics, and English ");
Console. WriteLine ("{0} {1} {2} {3}", name, Chinese, Math, English );
}
Public void set_name (string name1)
{
Name = name1;
}
Public void set_Chinese (double Chinese1)
{
Chinese = Chinese1;
}
Public void set_Math (double Math1)
{
Math = Math1;
}
Public void set_English (double English1)
{
English = English1;
}
Public double sum_score ()
{
Double sum = Chinese + Math + English;
Return sum;
}
Public double average_score ()
{
Double average = sum_score ()/3;
Return average;
}
}
}
Running result: