using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Assignment10 { class Program { static void Main(string[] args) { Console.WriteLine("歡迎進入調分程式"); Console.WriteLine("請輸入班級人數"); int num = int.Parse(Console.ReadLine()); Student[] allstudent = new Student[num]; for (int i = 0; i < num; i++) { allstudent[i]=new Student(); Console.WriteLine("請輸入"+(i+1)+"號姓名"); allstudent[i].Name = Console.ReadLine(); Console.WriteLine("請輸入{0}的國文成績",allstudent[i].Name); allstudent[i].Chinese=double.Parse(Console.ReadLine()); Console.WriteLine("請輸入{0}的英文成績", allstudent[i].Name); allstudent[i].English=double.Parse(Console.ReadLine()); Console.WriteLine("請輸入{0}的數學成績", allstudent[i].Name); allstudent[i].Math=double.Parse(Console.ReadLine()); Console.WriteLine("請輸入{0}的自然成績", allstudent[i].Name); allstudent[i].Science=double.Parse(Console.ReadLine()); Console.WriteLine("請輸入{0}的社會成績", allstudent[i].Name); allstudent[i].Society = double.Parse(Console.ReadLine()); Console.WriteLine("輸出" + (i + 1) + "號{0}同學原始成績", allstudent[i].Name); Console.WriteLine("國文:{0},英文:{1},數學:{2},自然:{3},社會:{4}", allstudent[i].Chinese, allstudent[i].English, allstudent[i].Math, allstudent[i].Science, allstudent[i].Society); allstudent[i].Change(); } Console.WriteLine("輸出調分後成績"); Console.WriteLine("座號\t姓名\t國文\t英文\t數學\t自然\t社會"); for (int i = 0; i < num; i++) { Console.WriteLine((i+1)+"\t{0}\t{1}\t{2}\t{3}\t{4}\t{5}",allstudent[i].Name, allstudent[i].Chinese, allstudent[i].English, allstudent[i].Math, allstudent[i].Science, allstudent[i].Society); } } } } .......................................................................................... using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Assignment10 { class Student { private double chinese; private double english; private double math; private double science; private double society; private string name; public Student() { chinese=0; english=0; math=0; science=0; society=0; name="未命名"; } public double Chinese { set { chinese = value; } get { return chinese; } } public double English { set { english = value; } get { return english; } } public double Math { set { math = value; } get { return math; } } public double Science { set { science = value; } get { return science; } } public double Society { set { society = value; } get { return society; } } public string Name { set { name = value; } get { return name; } } public void Change() { int counter = 0; Console.WriteLine("{0}平常出席率好嗎?輸入1:好 或 輸入0:不好",name); if (int.Parse(Console.ReadLine()) == 1) counter = counter + 1; Console.WriteLine("{0}平常交作業情形好嗎?輸入1:好 或 輸入0:不好",name); if (int.Parse(Console.ReadLine()) == 1) counter = counter + 1; Console.WriteLine("{0}同學有來考試嗎?輸入1:有 或 輸入0:沒有",name); if (int.Parse(Console.ReadLine()) == 1) counter = counter + 2; if (counter > 2) { math = System.Math.Round(10 * System.Math.Sqrt(math),2); chinese = System.Math.Round(10 * System.Math.Sqrt(chinese),2); english = System.Math.Round(10 * System.Math.Sqrt(english),2); if (society <= 60) society = 60; if (science <= 60) science = 60; } } ~Student() { } } }