标题:谁帮我看看哪里错了
只看楼主
因思及我
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2015-5-10
结帖率:0
 问题点数:0 回复次数:3 
谁帮我看看哪里错了
import *;
import java.util.*;
class  ScoreLL
{
    public static String[] inputScore() throws IOException
    {
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        return buf.readLine().split(" ");
        }
    public static void dataTransform(String input[],String name[],double test[],double regular[],int count)
    {
        name[count]=input[0];
        regular[count]=Double.parseDouble(input[1]);
        test[count]=Double.parseDouble(input[2]);
    }
    public static boolean isLegal(double score)
    {
        if ((0<=score)&&(score<=100))
        {
            return true;
        }
        else return false;
    }
    public static double score(double regular,double test)
    {
        return (regular*0.3+test*0.7);
    }
    public static void outputScore(String name[],double score[],char grade[])
        {
            System.out.println("姓名"+"\t"+"成绩"+"t"+"等级");
        for (int i=0;i<name.length ;i++ )
        {
            System.out.printf("%s\t %.1f\t %c\n",name[i],score[i],grade[i]);
        }
    }
    public static void main(String[] args) throws IOException
    {   BufferedReader buf;
        int num;
        String name[];
        double regular[];
        double test[];
        double score[];
        char grade[];
        System.out.print("请输入学生人数:");
        buf=new BufferedReader(new InputStreamReader(System.in));
        num=Integer.parseInt(buf.readLine());
        System.out.println(num);
        name = new String[num];
        regular = new double[num];
        test = new double[num];
        score = new double[num];
        grade = new char[num];
        System.out.println("请按照姓名 考试成绩 平时成绩输入!");
        for(int i=0;i<num;i++)
        {
           dataTransform(inputScore(),name,regular,test,i);
           if(isLegal(regular[i])&& isLegal(test[i]))
            {
               score[i]=score(regular[i],test[i]);
            }
            else
            System.out.println("输入有误,请重新输入");
        for(int j=i+1;j<num;j++)
            {
        if(score[i]>score[i+1])
            {
                double aa[]= new double[num];
                score[i]=aa[i];
                score[i+1]=score[i];
                aa[i]=score[i];
            }
            }
        }
        for(int i =0;i<num;i++)
        {
        if(score[i]>=85)
            System.out.println(name[i]+"\r综合成绩为:"+score[i]+"\n所属等级为:A");
        else if(75<=score[i]&&score[i]<85)
            System.out.println(name[i]+"\r综合成绩为:"+score[i]+"\n所属等级为:B");
        else if(65<=score[i]&&score[i]<75)
            System.out.println(name[i]+"\r综合成绩为:"+score[i]+"\n所属等级为:C");
        else
            System.out.println(name[i]+"\r综合成绩为:"+score[i]+"\n所属等级为:D");
        }
    }
}
输入是这样的,这是出了什么问题?

D:\作业\java大作业>java ScoreLL
请输入学生人数:2
2
请按照姓名 考试成绩 平时成绩输入!
li 86 57
l 89 87
综合成绩为:0.0
所属等级为:D
综合成绩为:88.39999999999999
所属等级为:A


[此贴子已经被作者于2016-10-29 22:57编辑过]

搜索更多相关主题的帖子: regular public return import count 
2016-10-29 20:54
kaosaier
Rank: 5Rank: 5
等 级:职业侠客
威 望:7
帖 子:124
专家分:303
注 册:2016-7-23
得分:0 
不要float等浮点型变量。

minecraft,我的最爱!
2016-10-30 11:55
益达炒鸡蛋
Rank: 2
等 级:禁止发言
帖 子:15
专家分:21
注 册:2016-10-30
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽
2016-10-30 15:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-470450-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.105210 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved