问题定义:设计一个网页,输入学生的详细信息,如学生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; } }
1 回答
凤凰求蛊
TA贡献1825条经验 获得超4个赞
只需修改代码:
public int persent(int total)
{
int p = (total * 100) / 300;
return p;
}
- 1 回答
- 0 关注
- 136 浏览
添加回答
举报
0/150
提交
取消