亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我的百分比值是在 c# 的文本框中打印“0”

我的百分比值是在 c# 的文本框中打印“0”

C#
回首憶惘然 2022-01-09 14:39:07
問題定義:設計一個網頁,輸入學生的詳細信息,如學生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;

 }


查看完整回答
反對 回復 2022-01-09
  • 1 回答
  • 0 關注
  • 150 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號