看板 TTU-Transfer 關於我們 聯絡資訊
來當好人了XD 不會java的人來賺看看p幣 第一次用顏色Q_Q class ptt { private static double pi=3.14; private static double area; //private static double area public void show() { System.out.println("area = "+ pi*r*r); } private ptt(double fa) { area = fa; //area = pi*r*r } } public class fate { public static void main(String args) { ptt pt[]=new ptt[3]; pt[0]=new fa(1,0); pt[1]=new fa(2,0); pt[2]=new fa(3,0); } } 9-13 class CScore { private String name; private int math; private int eng; private CScore(String str,int m,int e) { name = str; math = m; eng = e; } public void mathAvg(CScore c[]) { int sum = 0; for(int i = 0; i < c.length; i++) sum += c[i].math; System.out.println("The average of math is "); System.out.println((double)sum / c.length); // print out the average grade of Math } public void mathTop(CScore c[]) { int max = c[0].math; String str = c[0].name; for(int i = 0; i < c.length; i++) { if (c[i].math > max) { max = c[i].math; str = c[i].name; // If the next person's grade is higher than // the max grade, switch the top grade } } System.out.println("The top score of math is " + max); System.out.println("The name is " + str); // print out the top grade of math } public void engAvg(CScore c[]) { int sum = 0; for(int i = 0; i < c.length; i++) sum += c[i].eng; System.out.println("The average of english is "); System.out.println((double)sum / c.length); // print out the average grade of English } public void engTop(CScore c[]) { int max = c[0].eng; String str = c[0].name; for(int i = 0; i < c.length; i++) { if (c[i].eng > max) { max = c[i].eng; str = c[i].name; // If the next person's grade is higher than // the max grade, switch the top grade } } System.out.println("The top score of english is " + max); System.out.println("The name is " + str); // print out the top grade of English } public void show (CScore c[]) { System.out.println("Name" + "/t" + "Math" + "\t" + "English + "\t"); for (int i = 0; i < c.lenth; i++) { System.out.println(c[i].name + "\t" + c[i].math + "\t" + c[i].English + "\t"這好像要加個換行的指令?); } } } public class app9_13 { public static void main(String args[]) { CScore sco[] = new CScore sco[0] = new CScore("Fiona", 86, 92); sco[1] = new CScore("Ryan", 95, 79); sco[2] = new CScore("Ariel, 81, 83); sco[0].show(score); sco[0].mathAvg(score); sco[0].matTop(score); sco[0].engTop(score); } } 錯了不關我的事 要怪去怪derekwings (逃) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.166.159.205
fate9243 :有問題下面的主程式 錯誤= = 12/20 21:42
※ 編輯: ayudomoto 來自: 218.166.151.245 (12/20 22:14)
ayudomoto :你public 打成puvlic 12/20 22:15
fate9243 :...... 12/20 22:53
ayudomoto :我沒有執行java的東西 所以不能檢視對不對XD 12/20 23:06
fate9243 :好吧...........~"~ 12/20 23:21
derekwings :砍掉重練! 12/20 23:25
ayudomoto :你才砍掉重練 12/21 03:16
fate9243 :kerker! 12/22 23:19
jungle12345 :砍掉重練!!= = 12/23 02:58
jungle12345 :不是說你= = 12/23 03:02
jungle12345 :也不是說你= = 12/23 03:02
fate9243 :樓上好嗨喔= = 12/23 08:51
fate9243 :話說我英文不好可以麻煩改中文嘛= =?? 12/23 09:57
ayudomoto :什麼改中文? 12/24 23:39
fate9243 :註解阿 12/24 23:50
ayudomoto :這...好像沒有寫得很難... 12/25 18:56