标题:帮忙修改一下
取消只看楼主
qwhjyu
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-3-12
 问题点数:0 回复次数:0 
帮忙修改一下
    定义一个学生类,该类的功能如下:包含学生的姓名、性别、年龄、学号、Csharp课程成绩、Java课程成绩,在类中设计一个变量来记录共有多少学生,即共为该类生产多少个实例:具有可输出生产实例个数的成员函数;具有可输入/输出学生信息的成员函数;具有可计算学生总分和平均分的成员函数。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Student
{
    class Student
    {
        public static int num;
        int no;
        string name;
        string sex;
        int age;
        double csharp;
        double java;
        
        

        public int No
        {
            get { return no; }
            set { no = value; }
        }
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public string Sex
        {
            get { return sex; }
            set { sex = value; }
        }
        public int Age
        {
            get { return age; }
            set { age = value; }
        }
        public double Csharp
        {
            get { return csharp; }
            set { csharp = value; }
        }
        public double Java
        {
            get { return java; }
            set { java = value; }
        }

        //public int Num()
        //{
        //    num=
        //}
        public void input()
        {
         
        }
        public double Sum()
        {
            double sum;
            sum = csharp + java;
            return sum;
        }
        public double Avg()
        {
            double avg;
            avg = (csharp + java) / 2;
            return avg;
        }
        
    }
 class Program
    {
        static void Main(string[] args)
        {
            Student s = new Student();
            string x;
            int i = 1, j = 0;
            
            Console.WriteLine("                   学生信息管理系统");
            Console.WriteLine("--------------------------");
            Console.WriteLine("请输入学生的信息");
            Console.WriteLine("--------------------------");
            do
            {
                Console.Write("学号:");
                no = Convert.ToInt32(Console.ReadLine());
                Console.Write("姓名:");
                name = Console.ReadLine();
                Console.Write("性别:");
                sex = Console.ReadLine();
                Console.Write("年龄:");
                age = Convert.ToInt32(Console.ReadLine());
                Console.Write("c#成绩:");
                csharp = Convert.ToDouble(Console.ReadLine());
                Console.Write("java成绩:");
                java = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("还需要输入学生信息吗(yes/no)");
                x = Console.ReadLine();
            } while (x == "yes");
            Console.WriteLine("现在共有学生" + (i - 1) + "名");
            Console.WriteLine("\n--------------------------------------------------------------\n");
            Console.WriteLine("学号\t姓名\t性别\t年龄\tc#成绩\tjava成绩\t总成绩\t平均成绩");
            for (j = 0; j < (i - 1); j++)
            {
                Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t\t{6}\t{7}", s.No, s.Name, s.Sex, s.Age, s.Csharp, s.Java, s.Sum(), s.Avg());
            }
            Console.ReadLine();
        }
    }
}
搜索更多相关主题的帖子: 函数 生产 public Java 课程 
2012-03-19 19:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-363675-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.122495 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved