標題:
陣列 (五) - 成績表
[打印本頁]
作者:
tonyh
時間:
2021-1-26 13:12
標題:
陣列 (五) - 成績表
利用二維陣列, 試做一個包含五位同學, 各三組分數的成績表格.
表格的形式如下:
本帖隱藏的內容需要回復才可以瀏覽
作者:
劉凱閔
時間:
2021-1-26 13:43
public class Ch07 {
public static void main(String[] args) {
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={{78,89,66},
{77,67,34},
{90,98,91},
{57,59,81},
{45,66,92}};
int avg;
for(int i=0; i<6; i++)
System.out.print(title[i]+"\t");
System.out.println();
System.out.println("===========================================");
for(int i=0; i<5; i++)
{
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0; j<3; j++)
{
System.out.print(score[i][j]+"\t");
}
avg=Math.round(((float)score[i][0]+score[i][1]+score[i][2])/3);
System.out.println(avg);
}
}
}
複製代碼
作者:
吳聲寬
時間:
2021-1-26 13:50
public class Ch11
{
public static void main(String[] args)
{
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}};
int avg;
for(int i=0;i<6;i++)
System.out.print(title[i]+"\t");
System.out.println("\n===========================================");
for(int i=0;i<5;i++)
{
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0;j<3;j++)
System.out.print(score[i][j]+"\t");
avg=(score[i][0]+score[i][1]+score[i][2])/3;
System.out.println(avg);
}
}
}
複製代碼
作者:
王博裕
時間:
2021-1-26 13:51
public class dd {
public static void main(String[] args) {
String tittle[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={
{78,89,66},{77,67,34},{90,98,91},{57,59,81},{45,66,92}};
int avg;
for(int i=0; i<6; i++)
System.out.print(tittle[i]+"\t");
System.out.println();
System.out.println("=================================================");
for(int i=0;i<5;i++)
{
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0;j<3;j++)
{
System.out.print(score[i][j]+"\t");
}
avg=Math.round((float)(score[i][0]+score[i][1]+score[i][2])/3);
System.out.println(avg);
}
}
}
複製代碼
作者:
紀承典
時間:
2021-1-26 13:55
public class Ch01 {
public static void main(String[] args)
{
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={{90,85,85},{70,75,80},{80,95,80},{70,95,75},{80,85,95}};
int avg;
for(int i=0; i<6; i++)
System.out.print(title[i]+"\t");
System.out.println();
System.out.println("============================================================");
for(int i=0;i<5; i++)
{
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0; j<3; j++)
{
System.out.print(score[i][j]+"\t");
}
avg=Math.round((float)(score[i][0])+score[i][1]+score[i][2])/3);
System.out.println(avg);
}
}
複製代碼
作者:
楊澤全
時間:
2021-1-26 13:55
public class Ch07
{
public static void main(String[] args)
{
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大熊","怡靜","濟安","阿福"};
int score [][]={{78,89,66}
,{77,67,34}
,{90,98,91}
,{57,59,81}
,{45,66,92}};
int avg;
for(int i=0;i<6;i++)
System.out.print(title[i]+"\t");
System.out.println();
System.out.println("======================================================");
for(int i=0;i<5;i++)
{
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0;j<3;j++)
System.out.print(score[i][j]+"\t");
avg=Math.round((float)((score[i][0]+score[i][1]+score[i][2])/3));
System.out.println(avg);
}
}
}
複製代碼
作者:
楊小萱
時間:
2021-1-26 13:57
public class Ch05
{
public static void main(String[] args)
{
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={{90,85,85},{70,75,80},{80,95,80},{70,95,75},{80,85,95}};
int avg;
for(int i=0;i<6;i++)
System.out.print(title[i]+"\t");
System.out.println();
System.out.println("===========================================");
for(int i=0;i<5;i++)
{
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0;j<3;j++)
{
System.out.print(score[i][j]+"\t");
}
avg=Math.round((float)(score[i][0]+score[i][1]+score[i][2])/3);
System.out.println(avg);
}
}
}
複製代碼
作者:
李柏穎
時間:
2021-1-26 13:58
public class Ch03
{
public static void main(String[] args)
{
int avg;
String a[]={"座號","姓名","國文","英文","數學","平均"};
String b[]={"小叮噹","大雄","宜靜","技安","阿福"};
int c[][]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}};
for(int i=0; i<=5; i++)
System.out.print(a[i]+"\t");
System.out.println();
System.out.println("=========================================================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t"+b[i]+"\t");
for(int j=0; j<3; j++)
System.out.print(c[i][j]+"\t");
avg=(c[i][0]+c[i][1]+c[i][2])/3;
System.out.println(avg);
}
}
}
複製代碼
作者:
卓炘暘
時間:
2021-1-26 13:59
public class Ch01
{
public static void main(String args[])
{
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"多拉A夢","多拉B夢","多拉C夢","多拉D夢","多拉E夢"};
int score[][]={{78,89,66},
{77,67,34},
{90,98,91},
{57,59,81},
{45,66,92}};
int avg;
for(int i=0; i<6; i++)
System.out.print(title[i]+"\t");
System.out.println();
System.out.println("===========================================");
for(int i=0; i<5; i++)
{
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0; j<3; j++)
{
System.out.print(score[i][j]+"\t");
}
avg=Math.round((float)(score[i][0]+score[i][1]+score[i][2])/3);
System.out.println(avg);
}
}
}
複製代碼
作者:
王睿宇
時間:
2021-1-26 14:00
public class A01 {
public static void main(String[] args) {
String Title[]={"座號","姓名","國文","英文","數學","平均"};
for(int i=0; i<6; i++)
System.out.print(Title[i]+"\t");
System.out.println();
for(int i=0; i<44; i++)
System.out.print("=");
System.out.println();
String Person[][]={{"1","2","3","4","5"},{"甲","乙","丙","丁","戊"}};
int Score[][]={{90,70,80,70,80},{85,75,95,95,85},{85,80,80,75,95}};
for(int j=0; j<5; j+=1){
for(int k=0; k<2; k+=1)
System.out.print(Person[k][j]+"\t");
for(int l=0; l<3; l+=1)
System.out.print(Score[l][j]+"\t");
System.out.print((Score[0][j]+Score[1][j]+Score[2][j])/3);
System.out.println();
}
}
}
複製代碼
作者:
藍健洲
時間:
2021-1-26 14:01
import java.util.Scanner;
public class Ch01 {
public static void main(String[] args)
{
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,92}};
int avg;
for(int i=0;i<6;i++)
System.out.print(title[i]+"\t");
System.out.println();
System.out.println("===========================================");
for(int i=0;i<4;i++)
{
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0;j<3;j++)
System.out.print(score[i][j]+"\t");
avg=(score[i][0]+score[i][1]+score[i][2])/3;
System.out.println(avg);
}
}
}
複製代碼
作者:
紀承典
時間:
2021-1-26 14:18
public class Ch01 {
public static void main(String[] args)
{
int a[]={1,2,3,4}
int b[][]={{1,2,3,4},{1,2,3,4},{1,2,3,4}};
int c[][][]={{{1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4}}}
System.out.println(a.length); //4
System.out.println(b.length); //3
System.out.println(c.length); //2
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2