求java编成的“学生成绩管理”的小程序

能够进行简单的修改,计算总成绩,平均成绩。。。。。尽量用简单的java语言... 能够进行简单的修改,计算总成绩,平均成绩。。。。。尽量用简单的java语言 展开
 我来答
wanglong0537
推荐于2016-09-27 · TA获得超过370个赞
知道小有建树答主
回答量:300
采纳率:0%
帮助的人:221万
展开全部
import java.util.Arrays;
import java.util.Scanner;

public class SearchRecord {
static String[] name = { "张三", "李四", "王五", "宋六", "杨七", "罗八" };

static String[] subject = { "java", "c++", "oracle", "mysql", "jsp" };

static int[][] score = { { 84, 75, 69, 87, 54 }, { 90, 86, 81, 72, 59 },
{ 64, 92, 84, 86, 85 }, { 46, 58, 68, 67, 60 },
{ 97, 92, 96, 93, 91 }, { 82, 69, 64, 75, 73 } };

public static void main(String[] args) {
System.out.println("请输入:");
Scanner sca = new Scanner(System.in);
String str = sca.next();
if (str.equals("AVGCOU")) {
String s = sca.next();
avgcou(s);
} else if (str.equals("AVGSTU")) {
String s = sca.next();
avgstu(s);
} else if (str.equals("SORT")) {
String s = sca.next();
if (s.equals("sum"))
sortSum();
else
sortSubject(s);
} else if (str.equals("SUM"))
{
String s = sca.next();
sumScore(s);
} else if (str.equals("GET"))
{
String s1 = sca.next();
String s2 = sca.next();
getScore(s1,s2);
}
}

public static void avgcou(String s) {
int index = 0;
int sum = 0;
float avg = 0;
for (int i = 0; i < subject.length; i++) {
if (subject[i] .equals(s) ) {
index = i;
break;
}
}
System.out.println(index);
for (int i = 0; i < name.length; i++) {
sum += score[i][index];
}
avg = sum / name.length;
System.out.println("课程" + s + "的平均分是:" + avg);
}

public static void avgstu(String s) {
int index = 0;
int sum = 0;
float avg = 0;
for (int i = 0; i < name.length; i++) {
if (name[i] .equals(s) ) {
index = i;
break;
}
}
for (int i = 0; i < subject.length; i++) {
sum += score[index][i];
}
avg = sum / name.length;
System.out.println("学生" + s + "的平均分是:" + avg);
}

public static void sortSum() {
int temp = 0;
String s;
int[] sum = new int[6];
for (int i = 0; i < name.length; i++) {
for (int j = 0; j < subject.length; j++) {
sum[i] += score[i][j];
}
}
for (int i = 0; i < sum.length - 1; i++) {
for (int j = i + 1; j < sum.length; j++) {
if (sum[i] > sum[j]) {
temp = sum[i];
sum[i] = sum[j];
sum[j] = temp;
s = name[i];
name[i] = name[j];
name[j] = s;
}
}
}
System.out.println("按照总分进行升序排列的顺序是: ");
for (int i = 0; i < sum.length; i++) {
System.out.print(name[i] + ":");
System.out.println(sum[i]);
}
}

public static void sortSubject(String s) {
int index = 0;
int temp;
String str;
for (int i = 0; i < subject.length; i++) {
if (subject[i].equals(s) ) {
index = i;
break;
}
}
//System.out.println(index);
for (int i = 0; i < name.length - 1; i++) {
for (int j = i + 1; j <name.length; j++) {
if (score[i][index] > score[j][index]) {
temp = score[i][index];
score[i][index] = score[j][index];
score[j][index] = temp;
str = name[i];
name[i] = name[j];
name[j] = str;
}
}
}
System.out.println(subject[index]+"成绩按升序排列的顺序是: ");
for (int i = 0; i < name.length; i++) {
System.out.print(name[i] + ":");
System.out.println(score[i][index]);
}
}
public static void sumScore(String s)
{
int index=0;
int sum=0;
for (int i = 0; i < name.length; i++) {
if (name[i].equals(s) ) {
index = i;
break;
}
}
for (int i = 0; i<subject.length;i++)
{
sum+=score[index][i];
}
System.out.print(name[index]+"同学的总分是: ");
System.out.println(sum);
}
public static void getScore(String s1,String s2)
{
int index1 = 0;
int index2 = 0;
for (int i = 0; i < name.length; i++) {
if (name[i].equals(s1) ) {
index1 = i;
break;
}
}
for (int i = 0; i < subject.length; i++) {
if (subject[i].equals(s2) ) {
index2 = i;
break;
}
}
System.out.print(name[index1]+"同学"+subject[index2]+"的成绩是: ");
System.out.println(score[index1][index2]);
}
}

自己写的
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
OrgCool
2008-12-10 · TA获得超过115个赞
知道答主
回答量:70
采纳率:0%
帮助的人:42.5万
展开全部
要界面的吗
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式