import java.util.Scanner;

public class Main {

public static void main(String[] args) {
    double score = 0;
    double max = 0;
    String name = null;
    String maxname = null;
    int num;

    Scanner scanner = new Scanner(System.in);
    num = scanner.nextInt();
    int i = 0;

    do {
        name = scanner.next();
        score = scanner.nextDouble();

        if (max < score) {
            max = score;
            maxname = name;
        }

        i++;
    } while (i < num);

    System.out.println('The highest student name is:' + maxname);
}

}

Java 程序设计:使用 do...while 循环查找最高分学生姓名

原文地址: https://www.cveoy.top/t/topic/pcmv 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录