问题定义:设计一个网页,输入学生的详细信息,如学生ID、姓名、性别、流、任意3个科目的分数,根据大学规则计算总分、百分比、成绩并显示。
对于这个程序,我制作了 1 个类 Student.cs 来初始化所有变量,但我的显示 percen() 无法正常工作
学生
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class Student
{
int id;
string name;
string gender;
string stream;
int[] marks;
public int[] Marks1
{
get { return marks; }
set { marks = value; }
}
public Student( int id,string name,string gender,string stream,int[]
marks)
{
this.id = id;
this.name = name;
this.gender = gender;
this.stream = stream;
this.marks = marks;
}
public int Id
{
get { return id; }
set { id = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public int[] Marks
{
get { return marks; }
set { marks = value; }
}
public string Gender
{
get { return gender; }
set { gender = value; }
}
public string Stream
{
get { return stream; }
set { stream = value; }
}
public string toString()
{
return "name = "+name+"Id - "+id+"gendre = "+gender+"stream =
"+stream+"marks - "+marks;
}
public int calc_total(int []marks)
{int arr;
arr = marks[0] + marks[1] + marks[2];
return arr;
}
public int persent(int total)
{
int p = (total / 300) * 100;
return p;
}
}
凤凰求蛊
相关分类