標題:
陣列 (五) - 成績表
[打印本頁]
作者:
tonyh
時間:
2019-8-6 13:33
標題:
陣列 (五) - 成績表
利用二維陣列, 試做一個包含五位同學, 各三組分數的成績表格.
表格的形式如下:
本帖隱藏的內容需要回復才可以瀏覽
作者:
張郁庭
時間:
2019-8-6 14:15
本帖最後由 張郁庭 於 2019-8-6 14:16 編輯
public class Ch01
{
public static void main(String args[])
{
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={{84,95,78,0},
{84,62,75,0},
{75,65,84,0},
{84,95,75,0},
{64,65,74,89}};
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");
}
float average=(float)((score[i][0]+score[i][1]+score[i][2])/3);
System.out.println(Math.round(average));
}
}
}
複製代碼
作者:
鄭宇崴
時間:
2019-8-6 14:16
public class Ch30
{
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);
}
}
}
複製代碼
作者:
黃永恩
時間:
2019-8-6 14:19
public class Ch02
{
public static void main(String args[])
{
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={{90,85,85,0},{70,75,80,0},{80,95,80,0},{70,95,75,0},{80,85,95,0}};
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");
int avg=Math.round((float)((score[i][0]+score[i][1]+score[i][2])/3));
System.out.println(avg);
}
}
}
複製代碼
作者:
張書涵
時間:
2019-8-6 14:22
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}};
for(int i=0; i<=5; i++)
System.out.print(title[i]+"\t");
System.out.print("\n===============================================\n");
for(int i=0; i<=4; i++)
{
float avg;
avg=(score[i][0]+score[i][1]+score[i][2])/3;
avg=Math.round(avg);
System.out.print(i+1+"\t"+name[i]+"\t");
for(int j=0; j<=2; j++)
System.out.print(score[i][j]+"\t");
System.out.println((int)avg);
}
}
}
複製代碼
作者:
蔡明蓉
時間:
2019-8-6 14:22
public class Ch24 {
public static void main(String[] args){
String title[]={"座號","姓名","國文","英文","平均"};
String name[]={"小叮噹","大雄","靜香","胖虎","小夫"};
int score[][]={{78,87,56,0},{54,35,87,0},{65,54,87,0},{21,98,54,0}};
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++){
score[i][3]=Math.round((float)(score[i][0]+score[i][1]+score[i][2])/3);
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0;j<4;j++)
System.out.print(score[i][j]+"\t");
System.out.println();
}
}
}
複製代碼
作者:
潘憶承
時間:
2019-8-6 14:23
本帖最後由 潘憶承 於 2019-8-6 14:26 編輯
public class Ch02
{
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);
}
}
}
複製代碼
作者:
許育禎
時間:
2019-8-6 14:24
public class CH01
{
public static void main(String args[])
{
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={{99,100,96},{11,5,3},{91,89,95},{53,45,58},{77,78,82}};
float a;
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++)
{
a=(float)(Math.round(score[i][0]+score[i][1]+score[i][2])/3);
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0;j<3;j++)
{
System.out.print(score[i][j]+"\t");
}
System.out.println(a);
}
}
}
複製代碼
作者:
曾暘竣
時間:
2019-8-6 14:24
public class Ch10{
public static void main(String[]args)
{
String title[]={"號","名","國","英","數","平均"};
String name[]={"a","s","d","f","g","h"};
int score[][]={{90,88,89},
{70,67,54},
{89,88,90},
{17,33,56},
{77,79,46}};
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");
float avg=(float)(score[i][0]+score[i][1]+score[i][2])/3;
System.out.println(avg);
}
}
}
複製代碼
作者:
葉俠愷
時間:
2019-8-6 14:24
import java.util.Scanner;
public class Ch11
{
public static void main(String args[])
{String a[]={"座號","姓名","國文","英文","數學","平均"};
int s[]={1,2,3,4,5};
String n[]={"小叮噹","大雄","靜香","胖虎","小夫"};
int p[][]={
{90,85,86},
{70,75,80},
{80,95,80},
{70,95,75},
{80,85,95}
};
for( int i=0;i<6;i++)
{
System.out.print(a[i]+"\t");
}
System.out.println();
System.out.println("===============================================================");
for(int i=0;i<5;i++)
{
System.out.print(s[i]+"\t"+n[i]+"\t");
for(int j=0;j<3;j++)
{
System.out.print(p[i][j]+"\t");
}
System.out.println(Math.round((p[i][0]+p[i][1]+p[i][2])/3)+"\t");
}
}
}
複製代碼
作者:
莊鈞程
時間:
2019-8-6 14:25
本帖最後由 莊鈞程 於 2019-8-6 14:32 編輯
import java.util.Scanner;
public class Ch34 {
public static void main(String[] args){
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={{84,54,87,0}
,{54,45,41,0}
,{54,78,97,0}
,{100,25,1,0}
,{64,78,60,0}};
for(int i=0;i<6;i++)
System.out.print(title[i]+" \t");
System.out.println("\n============================================");
for(int i=0;i<5;i++){
float avg=(float)(score[i][0]+score[i][1]+score[i][2])/3;
System.out.print((i+1)+" \t"+name[i]+" \t");
for(int j=0;j<3;j++)
System.out.print(score[i][j]+" \t");
System.out.println(avg);
}
}
}
複製代碼
作者:
余奕廷
時間:
2019-8-6 14:26
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("\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);
}
}
}
複製代碼
作者:
許育慈
時間:
2019-8-6 14:28
public class Ch01{
public static void main(String args[]){
String subject[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int n[][]={{90,82,85,0},
{70,74,80,0},
{80,98,80,0},
{70,96,75,0},
{80,85,95,0}};
for(int i=0;i<6;i++)
System.out.print(subject[i]+"\t");
System.out.println("\n===========================================");
for(int j=0;j<5;j++){
System.out.print((j+1)+"\t"+name[j]+"\t");
n[j][3]=Math.round((float)(n[j][0]+n[j][1]+n[j][2])/3);
for(int k=0;k<4;k++)
System.out.print(n[j][k]+"\t");
System.out.println();
}
}
}
複製代碼
作者:
黃芊嬡
時間:
2019-8-6 14:32
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,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);
}
}
}
複製代碼
作者:
余映均
時間:
2019-8-6 14:34
本帖最後由 余映均 於 2019-8-6 14:39 編輯
public class Ch02 {
public static void main(String[] args) {
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={{98,65,48},
{97,85,96},
{84,95,75},
{65,85,60},
{89,92,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++)
{
avg=Math.round((float)(score[i][0]+score[i][1]+score[i][2])/3);
System.out.print((i+1)+"\t"+name[i]+"\t");
for(int j=0;j<3;j++)
System.out.print(score[i][j]+"\t");
System.out.println(avg);
}
}
}
複製代碼
作者:
何育翔
時間:
2019-8-6 14:40
{
String title[]={"座號","姓名","國文","英文","數學","平均"};
String name[]={"小叮噹","大雄","宜靜","技安","阿福"};
int score[][]={{90,85,85},
{70,75,80},
{80,95,80},
{70,95,81},
{80,85,95}};
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");
float avg=(float)(score[i][0]+score[i][1]+score[i][2])/3;
System.out.println(avg);
}
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2