java是否有;获取行“;?

java是否有;获取行“;?,java,Java,我是CS新手,我正在做这个在线java课程,这是一个笑话。我这么说是因为我们得到的书是15美元的书,是为孩子们“教”的夏令营定制的。书中没有任何地方有实际的java信息,它只是一堆程序。我四处搜索了一下,似乎找不到我要找的东西 我们要做的一件事是修改程序,使其能够显示名字和姓氏。我已经看过并看到,您可以使用两个字符串来获取名字和姓氏。有什么东西可以让整个产品线都用java吗 package computegrades; import java.util.Scanner; public class

我是CS新手,我正在做这个在线java课程,这是一个笑话。我这么说是因为我们得到的书是15美元的书,是为孩子们“教”的夏令营定制的。书中没有任何地方有实际的java信息,它只是一堆程序。我四处搜索了一下,似乎找不到我要找的东西

我们要做的一件事是修改程序,使其能够显示名字和姓氏。我已经看过并看到,您可以使用两个字符串来获取名字和姓氏。有什么东西可以让整个产品线都用java吗

package computegrades;
import java.util.Scanner;
public class ComputeGrades {
public static void main (String[] args) {
    String[] names = getNames();
    int[] scores = getScores(names);
    double average = computeAverage(scores);
    int highestIndex = getHighest(scores);
    int lowestIndex = getLowest(scores);
    System.out.format("Average = %3.2f\n", average);
    System.out.println("Highest = " + names[highestIndex] + ": " + scores [highestIndex]);
    System.out.println("Lowest = " + names[lowestIndex] + ": " + scores [lowestIndex]);
    printLetterGrades(names, scores);
}

public static void printLetterGrades(String[] names, int[] scores)  {
    for (int i = 0; i < names.length; i++)  {
        if (scores[i] >= 90)    {
            System.out.println(names[i] + ": A");
        } else if (scores[i] >= 80) {
            System.out.println(names[i] + ": B");
        } else if (scores[i] >= 70) {
            System.out.println(names[i] + ": C");
        } else if (scores[i] >= 60) {
            System.out.println(names[i] + ": D");
        } else {
            System.out.println(names[i] + ": F");
        }
    }
}
    public static String[] getNames() {
    Scanner input = new Scanner(System.in);
    System.out.println("How many students?");
    int n = input.nextInt();
    System.out.println("Please enter their first names:");
    String[] names = new String[n];
    for (int i = 0; i < names.length; i++)  {
        System.out.print("name " + (i + 1) + ": ");
        names[i] = input.next();
    }
    System.out.println("Thank you.");
    return names;
}
public static int[] getScores(String[] names)   {
    System.out.println("Now, please enter their scores:");
    Scanner input = new Scanner(System.in);
    int[] scores = new int[names.length];
    for (int i = 0; i < names.length; i++)  {
        System.out.print(names[i] + "'s ");
        System.out.print("score: ");
        while(!input.hasNextInt()){
            input.next();
            System.out.println("Please enter an integer for the score");
            System.out.print("scores: ");
        }
        scores[i] = input.nextInt();
    }
    return scores;
}
public static double computeAverage(int[] scores)  {
    double sum = 0;
    for (int i = 0; i < scores.length; i++) {
        sum += scores[i];
    }
    return sum / scores.length;
}
public static int getHighest(int[] scores)  {
    int highestIndex = Integer.MIN_VALUE;
    int highestScore = Integer.MIN_VALUE;
    for (int i = 0; i < scores.length; i++) {
        if (scores[i] > highestScore)   {
            highestScore = scores[i];
            highestIndex = i;
        }
    }
    return highestIndex;
}
public static int getLowest(int[] scores)   {
    int lowestIndex = Integer.MAX_VALUE;
    int lowestScore = Integer.MAX_VALUE;
    for (int i = 0; i < scores.length; i++) {
        if (scores[i] < lowestScore)    {
            lowestScore = scores[i];
            lowestIndex = i;
        }
    }
    return lowestIndex;
}
}
包计算;
导入java.util.Scanner;
公共类计算机积分{
公共静态void main(字符串[]args){
字符串[]名称=getNames();
int[]分数=获取分数(名称);
双倍平均值=计算平均值(分数);
int highestIndex=获得最高分数;
int lowestIndex=getLowest(得分);
System.out.format(“平均值=%3.2f\n”,平均值);
System.out.println(“Highest=“+names[highestIndex]+”:“+scores[highestIndex]);
System.out.println(“Lowest=“+names[lowestIndex]+”:“+scores[lowestIndex]);
打印字母等级(姓名、分数);
}
公共静态无效printLetterGrades(字符串[]名称,整数[]分数){
for(int i=0;i=90){
System.out.println(名称[i]+“:A”);
}否则如果(分数[i]>=80){
System.out.println(名称[i]+“:B”);
}否则如果(分数[i]>=70){
System.out.println(名称[i]+“:C”);
}否则如果(分数[i]>=60){
System.out.println(名称[i]+“:D”);
}否则{
System.out.println(名称[i]+“:F”);
}
}
}
公共静态字符串[]getNames(){
扫描仪输入=新扫描仪(System.in);
System.out.println(“有多少学生?”);
int n=input.nextInt();
System.out.println(“请输入他们的名字:”);
字符串[]名称=新字符串[n];
for(int i=0;i最高分数){
最高分数=分数[i];
高指数=i;
}
}
返回最高指数;
}
公共静态int getlower(int[]分数){
int lowestinex=整数的最大值;
int lowestScore=整数最大值;
for(int i=0;i
作为Java新手,您需要掌握的资源之一是Oracle文档页面,例如:

这将指导您了解
扫描仪的功能

具体来说,你应该寻找


.nextLine()

提示:如果您的“书”中没有您需要的信息,请尝试另一本;-)在这里发布一个问题之前,请先看一下Try learning from的.replicate,我认为它比Javadoc更适合初学者。