定义一个人类(Person类),该类中包含两个字段name,age。再定义一个学生类(Student类),它是Person类的派生类,该类中包含学号、英语成绩、数学成绩、语文成绩等字段。包含两个方法(方法名自定),一个方法的功能是计算总成绩并输出;另一个方法的功能是根据总成绩判断是否升学,总成绩>=200分时显示可以升学,否则显示不可升学。
在主函数中新建若干个student类的对象(四个以上),分别以学号,姓名,年龄,各科成绩作为参数。并分别调用上述的两个方法。

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.Text;namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                   Student x1 = new Student("1001", "学生1", 0x12, 90M, 91M, 92M);
                Console.WriteLine("学生:{0} 总成绩:{1} 升学标志:{2}", x1.name, x1.计算总成绩().ToString(), x1.升学().ToString());
                Student x2 = new Student("1002", "学生2", 0x12, 92M, 91M, 82M);
                Console.WriteLine("学生:{0} 总成绩:{1} 升学标志:{2}", x2.name, x2.计算总成绩().ToString(), x2.升学().ToString());
                Student x3 = new Student("1003", "学生3", 0x12, 90M, 71M, 92M);
                Console.WriteLine("学生:{0} 总成绩:{1} 升学标志:{2}", x3.name, x3.计算总成绩().ToString(), x3.升学().ToString());
                Student x4 = new Student("1004", "学生4", 0x12, 60M, 11M, 22M);
                Console.WriteLine("学生:{0} 总成绩:{1} 升学标志:{2}", x4.name, x4.计算总成绩().ToString(), x4.升学().ToString());
            }
        }    public class Person
        {
            // Fields
            private int _age;
            private string _name;        // Properties
            public int age
            {
                get
                {
                    return this._age;
                }
                set
                {
                    this._age = value;
                }
            }        public string name
            {
                get
                {
                    return this._name;
                }
                set
                {
                    this._name = value;
                }
            }
        }    public class Student : Person
    {
        // Fields
        private decimal _数学成绩;
        private string _学号;
        private decimal _英语成绩;
        private decimal _语文成绩;    // Methods
        public Student(string 学号, string name, int age, decimal 数学成绩, decimal 语文成绩, decimal 英语成绩)
        {
           
            this.name = name;
            this .age = age;
            this.学号 = 学号;
            this.数学成绩 = 数学成绩;
            this.语文成绩 = 语文成绩;
            this.英语成绩 = 英语成绩;
            
        }    public decimal 计算总成绩()
        {
            decimal sum=0;
            sum += this._数学成绩 + this._语文成绩 + this._英语成绩;
            return   sum ;
        }    public bool 升学()
        {
            return (decimal.Compare(this.计算总成绩(), 200M) >= 0);
        }    // Properties
        public decimal 数学成绩
        {
            get
            {
                return this._数学成绩;
            }
            set
            {
                this._数学成绩 = value;
            }
        }    public string 学号
        {
            get
            {
                return this._学号;
            }
            set
            {
                this._学号 = value;
            }
        }    public decimal 英语成绩
        {
            get
            {
                return this._英语成绩;
            }
            set
            {
                this._英语成绩 = value;
            }
        }    public decimal 语文成绩
        {
            get
            {
                return this._语文成绩;
            }
            set
            {
                this._语文成绩 = value;
            }
        }
    }
    }
      

  2.   

    先声明一下,我不是不好好学习的学生,只是我试了我的执行不了,要不找个大仙帮我一下。下面的 我就不会写了。可以帮我改改吗?
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace zy2
    {
       
       class Person
       {
           public string Name;
           public int Age;
           
    }class Student:Person
    {
        public string 学号;
        public int 英语成绩;
        public int 数学成绩;
        public int 语文成绩;
        public int 总分()
    {
         return this.英语成绩+this.数学成绩+this.语文成绩;
    }
        public Boolean 可以升学()
    {
         return this.总分()>=200;
    }
        public void setdata(string name1, int age1, string 学号1, int 英语成绩1, int 数学成绩1, int 语文成绩1)
        { Name = name1; Age = age1; 学号 = 学号1; 英语成绩 = 英语成绩1; 数学成绩 = 数学成绩1; 语文成绩 = 语文成绩1;  } 
    }class Program
    {     static void Main(String[] args)
         {
         var student1 = new Student {Name="张楠", 学号="1号",数学成绩=65,英语成绩=86,语文成绩=96};
         var student2 = new Student { Name = "雪碧", 学号 = "2号",英语成绩 = 80, 数学成绩=70,语文成绩 = 76};
         var student3 = new Student { Name = "许涵", 学号 = "3号" ,英语成绩=90,数学成绩=86,语文成绩=56};
         var student4 = new Student { Name = "尹平", 学号 = "4号",英语成绩=52,数学成绩=65,语文成绩=86 };     Console.WriteLine("{3}{0}同学的总分是,");  
    }

        }
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace zy2
    {
        class Person
        {
            public string Name { get; set; }
            public int Age { get; set; }    }    class Student : Person
        {
            public string 学号 { get; set; }
            public int 英语成绩 { get; set; }
            public int 数学成绩 { get; set; }
            public int 语文成绩 { get; set; }
            private int 获得总分()
            {
                return this.英语成绩 + this.数学成绩 + this.语文成绩;
            }
            public void 显示总分()
            {
                Console.WriteLine("总分等于{0}.", 获得总分());
            }
            public void 升学判断()
            {
                if (获得总分() >= 200) Console.WriteLine("可以升学."); else Console.WriteLine("不可以升学.");
            }
            public Student(string name1, int age1, string 学号1, int 英语成绩1, int 数学成绩1, int 语文成绩1)
            { 
                Name = name1;
                Age = age1; 
                学号 = 学号1; 
                英语成绩 = 英语成绩1;
                数学成绩 = 数学成绩1; 
                语文成绩 = 语文成绩1;
            }
        }    class Program
        {        static void Main(String[] args)
            {
                Student[] students = new Student[]
                {
                    new Student("张楠", 21, "1号", 86, 65, 96),
                    new Student("雪碧", 22, "2号", 70, 80, 76),
                    new Student("许涵", 21, "3号", 86, 90, 56),
                    new Student("尹平", 21, "4号", 65, 52, 86),
                    new Student("某某", 22, "5号", 30, 47, 27)
                };
                foreach (var item in students)
                {
                    Console.WriteLine("学生姓名:{0}", item.Name);
                    item.显示总分();
                    item.升学判断();
                    Console.WriteLine();
                }
            }
        }
    }
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace zy2
    {
        class Person
        {
            public string Name { get; set; }
            public int Age { get; set; }
        }    class Student : Person
        {
            public string 学号 { get; set; }
            public int 英语成绩 { get; set; }
            public int 数学成绩 { get; set; }
            public int 语文成绩 { get; set; }
            public int 获得总分()
            {
                return this.英语成绩 + this.数学成绩 + this.语文成绩;
            }
            public bool 可以升学()
            {
                return 获得总分() >= 200;
            }
            public void 显示总分()
            {
                Console.WriteLine("总分等于{0}.", 获得总分());
            }
            public void 显示升学判断()
            {
                if (可以升学()) Console.WriteLine("可以升学."); else Console.WriteLine("不可以升学.");
            }
            public Student(string name1, int age1, string 学号1, int 英语成绩1, int 数学成绩1, int 语文成绩1)
            {
                Name = name1;
                Age = age1;
                学号 = 学号1;
                英语成绩 = 英语成绩1;
                数学成绩 = 数学成绩1;
                语文成绩 = 语文成绩1;
            }
        }    class Program
        {
            static void Main(String[] args)
            {
                Student[] students = new Student[]
                {
                    new Student("张楠", 21, "1号", 86, 65, 96),
                    new Student("雪碧", 22, "2号", 70, 80, 76),
                    new Student("许涵", 21, "3号", 86, 90, 56),
                    new Student("尹平", 21, "4号", 65, 52, 86),
                    new Student("某某", 22, "5号", 30, 47, 27)
                };
                foreach (var item in students)
                {
                    Console.WriteLine("学生姓名:{0}", item.Name);
                    item.显示总分();
                    item.显示升学判断();
                    Console.WriteLine("{0}号{1}同学总分{2},{3}升学.", item.学号, item.Name, item.获得总分(), item.可以升学() ? "可以" : "不可以");
                    Console.WriteLine();
                }
            }
        }
    }
      

  5.   

    去掉
                    item.显示总分();
                    item.显示升学判断();
    这两行。不过根据题意,你需要调用它们,并且输出是这两个函数内部实现的。
      

  6.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace zy2
    {
        class Person
        {
            public string Name { get; set; }
            public int Age { get; set; }
        }    class Student : Person
        {
            public string 学号 { get; set; }
            public int 英语成绩 { get; set; }
            public int 数学成绩 { get; set; }
            public int 语文成绩 { get; set; }
            public int 获得总分()
            {
                return this.英语成绩 + this.数学成绩 + this.语文成绩;
            }
            public bool 可以升学()
            {
                return 获得总分() >= 200;
            }
            public void 显示总分()
            {
                Console.Write("总分是{0},", 获得总分());
            }
            public void 显示升学判断()
            {
                if (可以升学()) Console.WriteLine("可以升学."); else Console.WriteLine("不可以升学.");
            }
            public Student(string name1, int age1, string 学号1, int 英语成绩1, int 数学成绩1, int 语文成绩1)
            {
                Name = name1;
                Age = age1;
                学号 = 学号1;
                英语成绩 = 英语成绩1;
                数学成绩 = 数学成绩1;
                语文成绩 = 语文成绩1;
            }
        }    class Program
        {
            static void Main(String[] args)
            {
                Student[] students = new Student[]
                {
                    new Student("张楠", 21, "1号", 86, 65, 96),
                    new Student("雪碧", 22, "2号", 70, 80, 76),
                    new Student("许涵", 21, "3号", 86, 90, 56),
                    new Student("尹平", 21, "4号", 65, 52, 86),
                    new Student("某某", 22, "5号", 30, 47, 27)
                };
                foreach (var item in students)
                {
                    Console.Write("{0}号{1}同学", item.学号, item.Name);
                    item.显示总分();
                    item.显示升学判断();
                }
            }
        }
    }
    最后给你一个代码。另外,你瞒不过我,之前的代码绝对不是你写的,至少不是你独立完成的。