急急急 求大神 Java编程 ,从键盘输入十个同学的3门功课的成绩,并输出它们的总分从高到 java编程 保存十个同学的三门功课成绩使用二维数组
Java\u7f16\u7a0b \u4fdd\u5b5810\u4e2a\u540c\u5b66\u76843\u95e8\u529f\u8bfe\u7684\u6210\u7ee9\uff0c\u5e76\u8f93\u51fa\u5b83\u4eec\u7684\u603b\u6210\u7ee9\u4e09\u4e2a\u8868,\u4e00\u4e2a\u5b66\u751f\u8868\uff0c\u4e00\u4e2a\u529f\u8bfe\u8868\uff0c\u4e00\u4e2a\u6210\u7ee9\u8868\u3002
\u6210\u7ee9\u8868\u6709\u5b66\u751fID\uff0c\u529f\u8bfeID\u548c\u6210\u7ee9\u3002
\u8fd9\u6837\u5c31\u80fd\u5b58\u597d\u6570\u636e\u4e86
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
int[][] a = new int[10][3];
String str[] = { "A", "B", "C" };
Scanner scan = new Scanner(System.in);
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
System.out.print("\u8f93\u5165\u7b2c" + (1 + i) + "\u4f4d\u540c\u5b66\u7684" + str[j] + "\u7684\u5206\u6570\uff1a");
a[i][j] = scan.nextInt();
}
}
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
System.out.println("\u7b2c" + (1 + i) + "\u4f4d\u540c\u5b66\u7684" + str[j] + "\u7684\u5206\u6570\u4e3a\uff1a"+a[i][j]);
}
}
}
}
你需要了解Arrays这个工具类,Scanner类
public static void tenStudents()
{
//十个同学3科成绩,总分
int[][] strs = new int[10][4];
int allSumScore = 0;
System.out.println("开始录入"+strs.length+"个同学的成绩:");
for(int i=0;i<strs.length;i++)
{
int everyOneSumScore = 0;
int score = 0;
for(int j=0;j<3;j++)
{
System.out.println("录入第"+(i+1)+"个同学的第"+(j+1)+"课的成绩:");
Scanner sc = new Scanner(System.in);
String ss = sc.next();
try
{
score = Integer.parseInt( ss );
}
catch ( NumberFormatException e )
{
//e.printStackTrace();
System.out.println("输入非int型,所以全为:"+score);
}
strs[i][j] = score;
everyOneSumScore += score;
}
//这里存放总数
strs[i][3] = everyOneSumScore;
allSumScore += everyOneSumScore;
}
System.out.println("--------------------------\n");
System.out.println("输出所有的记录\n");
int[] intScores = new int[strs.length];
for(int i=0;i<strs.length;i++)
{
intScores[i] = strs[i][3];
System.out.println("第"+(i+1)+"个同学的成绩(最后一个数为总数):"+Arrays.toString( strs[i] ));
}
Arrays.sort(intScores); //从低到高排序
StringBuffer sb = new StringBuffer();
for(int i=intScores.length-1;i>=0;i--)
{
sb.append( intScores[i] );
sb.append( " " );
}
System.out.println("从高到底的排序:"+sb.toString( ).trim( ));
System.out.println("\n最后的总数为:"+allSumScore);
}
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
int[][] a = new int[10][3];
String str[] = { "A", "B", "C" };
Scanner scan = new Scanner(System.in);
List<Integer> list=new ArrayList<Integer>();
for (int i = 0; i < 10; i++) {
int sum=0;
for (int j = 0; j < 3; j++) {
System.out.print("输入第" + (1 + i) + "位同学的" + str[j] + "的分数:");
a[i][j] = scan.nextInt();
sum+=a[i][j];
}
list.add(sum);
}
Collections.sort(list);
System.out.println(list);
}
}
class Sort implements Comparator<Integer> {
@Override
public int compare(Integer o1, Integer o2) {
// TODO Auto-generated method stub
return -(o1-o2);
}
}
#include
#define N 10
void main()
{
float score[3],add[10]={0},add1[3]={0};
int i,j;
for(i=0;i
扩展阅读:java入门 ... 本科自学java工作好找吗 ... java学习 ... 零基础java自学教程 ... java编程求最大公约数 ... java python ... 免费学java编程的网站 ... java学会了好找工作吗 ... 手机版java ...